A clean, minimal starter to build authenticated apps with:
- Next.js (App Router)
- Clerk (Authentication)
- Convex (Backend + Database)
Includes protected routes, automatic user sync, and a solid foundation to start building real apps.
- π Authentication with Clerk
- π§± Convex backend with schema & functions
- π Automatic user sync (Clerk β Convex)
- π‘οΈ Route protection via middleware
- π― Clean app structure (auth vs app separation)
- β‘ Minimal, production-ready UI
- π§ͺ Ready for queries & mutations
.
βββ convex/ # Convex backend (schema, functions)
βββ src/
β βββ app/
β β βββ (auth)/ # Sign-in / Sign-up
β β βββ (app)/ # Protected routes (dashboard)
β β βββ globals.css # Global css file
β β βββ page.tsx # Public landing page
β βββ components/
β β βββ providers/ # Convex provider
β β βββ shared/ # UserSync.ts
β βββ middleware.ts # Clerk route protection
βββ .env.example
βββ README.md
Before getting started, make sure you have the following:
- Node.js v18 or higher
- A Clerk account with an application set up
- A Convex account with a project created
git clone https://github.com/harsh661/nextjs-clerk-convex-starter.git
cd nextjs-clerk-convex-starternpm installcp .env.example .env.localThen fill in .env.local:
# Convex
CONVEX_DEPLOYMENT=
NEXT_PUBLIC_CONVEX_URL=
NEXT_PUBLIC_CONVEX_SITE_URL=
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL=/dashboard
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=/dashboard
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
β οΈ Important β Convex + Clerk IntegrationIn your Convex Dashboard β Settings β Environment Variables, add:
CLERK_JWT_ISSUER_DOMAIN=https://your-clerk-domain.clerk.accounts.dev
npx convex devnpm run devVisit β http://localhost:3000
| Route | Access |
|---|---|
/ |
Public |
/sign-in, /sign-up |
Public |
/dashboard |
Protected |
Route protection is handled in middleware.ts.
Users are automatically synced to Convex on sign-in. No manual setup required.
| Variable | Description |
|---|---|
CONVEX_DEPLOYMENT |
Your Convex deployment slug |
NEXT_PUBLIC_CONVEX_URL |
Public Convex URL |
NEXT_PUBLIC_CONVEX_SITE_URL |
Public Convex site URL |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk publishable key |
CLERK_SECRET_KEY |
Clerk secret key |
NEXT_PUBLIC_CLERK_SIGN_IN_URL |
Path for the sign-in page |
NEXT_PUBLIC_CLERK_SIGN_UP_URL |
Path for the sign-up page |
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL |
Always redirects here after sign-in |
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL |
Always redirects here after sign-up |
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL |
Fallback redirect if no target after sign-in |
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL |
Fallback redirect if no target after sign-up |
| Variable | Description |
|---|---|
CLERK_JWT_ISSUER_DOMAIN |
Your Clerk JWT issuer domain |


