Skip to content

feat(web): integrate Clerk authentication with Convex#30

Merged
RISHII7 merged 1 commit into
developfrom
feature/clerk-auth
Jun 30, 2026
Merged

feat(web): integrate Clerk authentication with Convex#30
RISHII7 merged 1 commit into
developfrom
feature/clerk-auth

Conversation

@RISHII7

@RISHII7 RISHII7 commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Clerk authentication to apps/web with protected routes, sign-in/sign-up pages, and middleware
  • Integrate Clerk session tokens into the Convex client via ConvexProviderWithClerk
  • Gate the add mutation behind ctx.auth.getUserIdentity() in packages/backend
  • Fix deprecated baseUrl in backend tsconfig and add node types for auth.config.ts

Changes Made

apps/web — authentication

  • package.json — added @clerk/nextjs ^7.5.9
  • app/layout.tsx — ClerkProvider wraps the entire app
  • app/page.tsx — Authenticated/Unauthenticated guards; UserButton when signed in, SignInButton when not
  • components/theme-provider.tsx — replaced ConvexProvider with ConvexProviderWithClerk; removed dead ThemeHotkey / isTypingTarget / NextThemesProvider code
  • proxy.ts — Clerk middleware (Next.js 16 filename); protects all routes except /sign-in and /sign-up
  • app/(auth)/layout.tsx — centered layout for auth pages
  • app/(auth)/sign-in/[[...sign-in]]/page.tsx — Clerk hosted SignIn UI
  • app/(auth)/sign-up/[[...sign-up]]/page.tsx — Clerk hosted SignUp UI

apps/widget — cleanup

  • components/theme-provider.tsx — removed dead ThemeHotkey, isTypingTarget, NextThemesProvider code

packages/backend — auth hardening

  • convex/auth.config.ts — Clerk JWT provider config; /// <reference types=node /> for process.env in CLI context
  • convex/users.ts — add mutation now requires authentication via ctx.auth.getUserIdentity()
  • package.json — added @types/node ^20.19.41
  • tsconfig.json — removed deprecated baseUrl (unnecessary in TS 5+)

CI

  • ci.yml, release.yml, codeql.yml — NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY added to build env from GitHub repo variable

Testing

  • pnpm lint — clean (0 errors)
  • pnpm typecheck — clean (0 errors)
  • pnpm build — all 4 routes built: /, /_not-found, /sign-in, /sign-up
  • Middleware detected: Æ’ Proxy (Middleware) in build output

Test environment:

  • OS: Windows 11 Pro
  • Node: 22.15.1

Checklist

  • Follows Conventional Commits format
  • No secrets committed (Clerk key in GitHub repo variable, .env.local gitignored)
  • Lint, typecheck, and build all pass locally before pushing

🤖 Generated with Claude Code

Add end-to-end Clerk authentication to apps/web, wire it into the
Convex backend via ConvexProviderWithClerk, and gate the add mutation
behind identity verification.

apps/web — authentication integration
- package.json: add @clerk/nextjs ^7.5.9
- app/layout.tsx: wrap root layout with ClerkProvider
- app/page.tsx: guard UI with Authenticated/Unauthenticated components;
  show UserButton when signed in and SignInButton when signed out
- components/theme-provider.tsx: replace ConvexProvider with
  ConvexProviderWithClerk (useAuth from @clerk/nextjs) so Convex
  receives the active Clerk session token; remove dead ThemeHotkey,
  isTypingTarget, NextThemesProvider, and useTheme code
- proxy.ts (Next.js 16 middleware): add clerkMiddleware() protecting all
  non-public routes; public routes: /sign-in(.*), /sign-up(.*)
- app/(auth)/layout.tsx: centered layout for auth pages
- app/(auth)/sign-in/[[...sign-in]]/page.tsx: Clerk hosted SignIn component
- app/(auth)/sign-up/[[...sign-up]]/page.tsx: Clerk hosted SignUp component

apps/widget — cleanup
- components/theme-provider.tsx: remove dead ThemeHotkey, isTypingTarget,
  NextThemesProvider, and useTheme code; simplify to bare ConvexProvider

packages/backend — auth configuration and hardening
- convex/auth.config.ts: Clerk JWT provider config using
  CLERK_JWT_ISSUER_DOMAIN; node types via triple-slash reference since
  this file runs in Node.js (Convex CLI), not the V8 function runtime
- convex/users.ts: gate add mutation behind ctx.auth.getUserIdentity()
  — throws "Not Authenticated" for unauthenticated callers
- package.json: add @types/node ^20.19.41 (needed for auth.config.ts)
- tsconfig.json: remove deprecated baseUrl (not required for paths in TS 5+)

CI/tooling
- ci.yml, release.yml, codeql.yml: add NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
  to build env (read from GitHub repo variable NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY)
  so ClerkProvider initialises without throwing during next build in CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@RISHII7
RISHII7 merged commit f072f1d into develop Jun 30, 2026
7 checks passed
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/clerk-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@RISHII7
RISHII7 deleted the feature/clerk-auth branch June 30, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant