A modern full-stack TypeScript starter template with authentication, real-time database, and beautiful UI components.
- Frontend: Next.js 15 with App Router, Tailwind CSS 4
- Backend: Convex (real-time database and serverless functions)
- Authentication: Clerk
- Language: TypeScript
- Styling: Tailwind CSS with shadcn/ui components
Before you begin, make sure you have:
- Node.js 18+ installed
- npm or yarn package manager
- A Clerk account (free)
- A Convex account (free)
git clone <your-repo-url>
cd template-nextjs-clerk
npm install-
Create a Convex account: Go to convex.dev and sign up
-
Install Convex CLI:
npm install -g convex
-
Login to Convex:
npx convex login
-
Initialize your project:
npx convex dev
- This will create a new Convex project and give you a deployment URL
- Copy the deployment URL (it looks like
https://your-project.convex.cloud)
- Create a Clerk account: Go to clerk.com and sign up
- Create a new application in your Clerk dashboard
- Get your keys from the Clerk dashboard:
- Go to "API Keys" in your Clerk dashboard
- Copy the "Publishable key" and "Secret key"
This is critical for Clerk to work with Convex:
- In your Clerk dashboard, go to "JWT Templates"
- Click "New template"
- Select "Convex" from the list
- Name it
convex(lowercase) - Set the Issuer to your Clerk domain (e.g.,
https://your-app.clerk.accounts.dev) - Save the template
Create a .env.local file in your project root:
# Convex
NEXT_PUBLIC_CONVEX_URL=https://your-project.convex.cloud
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...Where to find these:
NEXT_PUBLIC_CONVEX_URL: From step 2 when you rannpx convex devNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: Clerk dashboard → API Keys → Publishable keyCLERK_SECRET_KEY: Clerk dashboard → API Keys → Secret key
-
Go to your Convex dashboard
-
Select your project
-
Go to "Settings" → "Environment Variables"
-
Add this variable:
CLERK_JWT_ISSUER_DOMAIN=https://your-app.clerk.accounts.dev
(Replace with your actual Clerk issuer domain from step 4)
Update convex/auth.config.ts with your Clerk domain:
export default {
providers: [
{
domain: "https://your-app.clerk.accounts.dev", // Replace with your domain
applicationID: "convex",
},
]
};# Run both frontend and backend
npm run devThis starts:
- Next.js frontend at
http://localhost:3000 - Convex backend (dashboard opens automatically)
# Frontend only
npm run dev:frontend
# Backend only
npm run dev:backend# Build for production
npm run build
# Start production server
npm startnpm run dev- Start development servers (frontend + backend)npm run dev:frontend- Start Next.js frontend onlynpm run dev:backend- Start only Convex backendnpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
├── app/ # Next.js pages (App Router)
├── components/ # React components
├── convex/ # Backend functions and schema
│ ├── auth.config.ts # Clerk authentication config
│ ├── schema.ts # Database schema
│ └── myFunctions.ts # Server functions
├── public/ # Static assets
├── middleware.ts # Route protection
└── ...
This template includes:
- Sign up/Sign in pages via Clerk
- Protected routes using middleware
- User session management
- Integration between Clerk and Convex for authenticated API calls
Convex provides:
- Real-time database with TypeScript schema
- Serverless functions
- Real-time subscriptions
- Automatic scaling
Define your schema in convex/schema.ts and create functions in convex/myFunctions.ts.
-
"Convex client not configured"
- Check your
NEXT_PUBLIC_CONVEX_URLin.env.local - Make sure Convex dev server is running
- Check your
-
Authentication not working
- Verify JWT template is created in Clerk with issuer domain
- Check
CLERK_JWT_ISSUER_DOMAINin Convex dashboard - Ensure
convex/auth.config.tshas correct domain
-
Build errors
- Run
npm run lintto check for linting issues - Ensure all environment variables are set
- Run
- Push your code to GitHub
- Connect your repo to Vercel
- Add your environment variables in Vercel dashboard
- Deploy!
Convex automatically deploys when you push to your main branch. Configure this in your Convex dashboard under "Settings" → "Deploy Settings".
This project is open source and available under the MIT License.
Happy coding! 🎉
For questions or issues, please open a GitHub issue or check the documentation links above.