Skip to content

feat: integrate Clerk for authentication and update layout components - #2

Merged
ladaniprem merged 1 commit into
masterfrom
03-Clerk-authentication
Jun 8, 2026
Merged

ladaniprem merged 1 commit into
masterfrom
03-Clerk-authentication

Conversation

@ladaniprem

@ladaniprem ladaniprem commented Jun 8, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added authentication system with sign-in and sign-up pages
    • Implemented user authentication and session management
    • Added protected routes that require authentication
    • Conditional UI based on authentication status (authenticated users see user management features, unauthenticated users see sign-in option)
    • Added user creation functionality

Copilot AI review requested due to automatic review settings June 8, 2026 14:37
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: f2ca508b-ee9e-47b6-84c3-9765c5df21e7

📥 Commits

Reviewing files that changed from the base of the PR and between 50f3750 and 3e8a2f0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • apps/web/app/(auth)/layout.tsx
  • apps/web/app/(auth)/sign-in/[[...sign-in]]/page.tsx
  • apps/web/app/(auth)/sign-up/[[...sign-up]]/page.tsx
  • apps/web/app/layout.tsx
  • apps/web/app/page.tsx
  • apps/web/components/theme-provider.tsx
  • apps/web/package.json
  • apps/web/proxy.ts
  • apps/widget/tsconfig.json
  • packages/backend/convex/auth.config.ts
  • packages/backend/convex/tsconfig.json
  • packages/backend/convex/users.ts
  • packages/backend/package.json
  • packages/backend/tsconfig.json

📝 Walkthrough

Walkthrough

This PR integrates Clerk authentication into the AetherLive application. It adds Clerk sign-in and sign-up pages, protects routes via middleware, integrates Clerk identity with Convex on the frontend, and enforces authentication in backend Convex mutations.

Changes

Clerk Authentication Integration with Convex Backend

Layer / File(s) Summary
Clerk UI Routes and Dependencies
apps/web/package.json, apps/web/app/(auth)/layout.tsx, apps/web/app/(auth)/sign-in/[[...sign-in]]/page.tsx, apps/web/app/(auth)/sign-up/[[...sign-up]]/page.tsx
Adds @clerk/nextjs dependency and creates auth route structure: centered layout wrapper for protected routes, sign-in page rendering Clerk SignIn component, and sign-up page rendering Clerk SignUp component.
Root Layout ClerkProvider Setup
apps/web/app/layout.tsx
Imports and wraps the root layout with ClerkProvider, making Clerk identity available throughout the app.
Frontend Convex-Clerk Provider Integration
apps/web/components/theme-provider.tsx
Replaces ConvexProvider with ConvexProviderWithClerk, adds runtime validation for NEXT_PUBLIC_CONVEX_URL environment variable, and passes useAuth hook to bind Clerk authentication to Convex.
Client Page Authentication UI
apps/web/app/page.tsx
Converts home page to a client component; authenticated users see UserButton, an "Add User" button, and user data, while unauthenticated users see a SignInButton.
Route Protection Middleware
apps/web/proxy.ts
Adds Clerk middleware that designates /sign-in and /sign-up as public routes, protects all others with auth.protect(), and exports matcher patterns to apply middleware globally except Next.js internals while always protecting API and tRPC routes.
Backend Convex Authentication Configuration
packages/backend/convex/auth.config.ts, packages/backend/convex/tsconfig.json, packages/backend/convex/users.ts, packages/backend/package.json, packages/backend/tsconfig.json
Configures Convex to use Clerk as an auth provider, adds Node.js type definitions to both Convex and backend tsconfigs, enforces identity check in the add mutation via ctx.auth.getUserIdentity(), and updates TypeScript configurations to support the auth setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through Clerk's bright door,
Auth guards the gates forevermore,
Convex and Clerk in harmony blend,
Protected routes from start to end! 🛡️✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@ladaniprem
ladaniprem merged commit 43bd44d into master Jun 8, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Clerk-based authentication to the apps/web Next.js app and wires it into Convex, alongside related backend Convex auth configuration and TypeScript config updates.

Changes:

  • Add Clerk to apps/web, wrap the app with ClerkProvider, and add Sign In/Sign Up routes.
  • Switch the web client to ConvexProviderWithClerk and add an auth check in the backend users.add mutation.
  • Update workspace lockfile and TypeScript configuration (including Node types) to support the new dependencies.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds Clerk packages and related transitive dependencies to the workspace lockfile.
packages/backend/tsconfig.json Adjusts TS compiler options (incl. ignoreDeprecations) and formatting.
packages/backend/package.json Adds @types/node to backend devDependencies.
packages/backend/convex/users.ts Adds an authentication check before inserting a user.
packages/backend/convex/tsconfig.json Adds Node types for Convex TS compilation.
packages/backend/convex/auth.config.ts Introduces Convex auth provider configuration for Clerk.
apps/widget/tsconfig.json Updates ignoreDeprecations value.
apps/web/proxy.ts Adds Clerk middleware implementation (but currently not in a middleware.ts file).
apps/web/package.json Adds @clerk/nextjs dependency to the web app.
apps/web/components/theme-provider.tsx Switches to ConvexProviderWithClerk and adds env var validation for Convex URL.
apps/web/app/page.tsx Adds authenticated/unauthenticated UI with Clerk components.
apps/web/app/layout.tsx Wraps the app with ClerkProvider.
apps/web/app/(auth)/sign-up/[[...sign-up]]/page.tsx Adds Clerk-hosted sign-up page route.
apps/web/app/(auth)/sign-in/[[...sign-in]]/page.tsx Adds Clerk-hosted sign-in page route.
apps/web/app/(auth)/layout.tsx Adds a centered layout wrapper for auth routes.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/web/proxy.ts
Comment on lines +1 to +3
import { clerkMiddleware,createRouteMatcher } from '@clerk/nextjs/server'

const isPublicRoute = createRouteMatcher([
Comment thread apps/web/proxy.ts
Comment on lines +10 to +16
const { userId } = await auth();
if (!isPublicRoute(req)) {
await auth.protect();
if (!userId) {
throw new Error("Not authenticated");
}
}
Comment on lines +4 to +8
import { ClerkProvider } from "@clerk/nextjs"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { ConvexProvider, ConvexReactClient } from "convex/react"
import { ConvexReactClient } from "convex/react"
import { ConvexProviderWithClerk} from "convex/react-clerk"
import {useAuth} from "@clerk/nextjs"
Comment on lines +1 to +14
import { AuthConfig } from "convex/server";

export default {
providers: [
{
// Replace with your Clerk Frontend API URL
// or with `process.env.CLERK_JWT_ISSUER_DOMAIN`
// and configure CLERK_JWT_ISSUER_DOMAIN on the Convex Dashboard
// See https://docs.convex.dev/auth/clerk#configuring-dev-and-prod-instances
domain: process.env.CLERK_JWT_ISSUER_DOMAIN!,
applicationID: "convex",
},
]
} satisfies AuthConfig;
Comment thread apps/web/app/page.tsx
Comment on lines +27 to +30
// function Content() {
// const messages = useQuery(api.messages.getForCurrentUser);
// return <div>Authenticated content: {messages?.length}</div>;
// } No newline at end of file
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.

2 participants