A minimal, production-ready boilerplate integrating Next.js 16, Clerk (authentication), and Convex (database).
It provides a preconfigured setup for auth, database, and API routes — so you can start building features instead of wiring dependencies.
- 🔐 Clerk Authentication — fully wired with Next.js middleware and React providers.
- 💾 Convex Database — backend functions, queries, and mutations ready for use.
- 🔄 Convex + Clerk Integration — JWT template configured for secure identity sharing.
- 🧱 Minimal Dashboard — shows auth state, Convex connectivity, API checks, and environment variables.
- 🧭 Protected Routes & APIs —
/protectedroute via Clerk middleware,/api/private/checkfor manualauth()testing. - 🩺 Health Check —
/api/healthpublic endpoint for uptime verification. - 🌀 TailwindCSS
git clone https://github.com/bitcraft3r/connext-boilerplate.git
cd connext-boilerplate
pnpm installnpx convex devThis creates the /convex directory and generates CONVEX_DEPLOYMENT and NEXT_PUBLIC_CONVEX_URL in .env.local.
- Create a new Clerk project at clerk.com.
- Enable Email and Google sign-in (default).
- Copy your keys to
.env.local:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
- Create a JWT Template → choose Convex → click Save Changes → copy the Issuer URL.
CLERK_JWT_ISSUER_DOMAIN=https://your-tenant.clerk.accounts.dev
- Add the same key in your Convex dashboard (Environment Variables).
- Configured via
ClerkProvider(App layout) andclerkMiddleware(Edge runtime). - Protects
/protectedroutes automatically. - Uses
auth()in server routes for identity access.
- Integrated with
ConvexProviderWithClerkfor client auth context. - Contains sample queries (
hello) and mutations (ping). - Includes a user provisioning mutation (
ensureUser) linked to Clerk’s user data.
- Uses the App Router (
src/app) and modular client/server components. middleware.tshandles auth at the edge;/apiroutes demonstrate protected and public APIs.
src/
app/
page.tsx # Dashboard (server component)
protected/ # Example protected route
api/
health/route.ts # Public health endpoint
private/check/route.ts # Protected API with manual auth() check
components/ # Reusable UI & provider components
middleware.ts # Clerk edge middleware
convex/
schema.ts # Convex DB schema
users.ts # ensureUser + me queries
queries.ts, mutations.ts # hello + ping examples
.env.example # Template for environment variables
Run both Next.js and Convex locally:
npx convex dev
pnpm devVisit:
/→ Dashboard with live integration checks/protected→ Middleware-protected page/api/health→ Public JSON response/api/private/check→ Returns401if signed out, or user info if signed in
Deploy easily on Vercel (Next.js) and Convex Cloud:
- Add all environment variables in your Vercel project settings.
- Ensure the Convex deployment matches the URL in
NEXT_PUBLIC_CONVEX_URL. - Update Clerk allowed origins to include your deployed domain.