This template provides a minimal setup to get Convex working with Next.js. It uses Auth.js for user authentication.
Clone the template and install dependencies:
npm create convex@latest -- -t get-convex/convex-nextauth-template
Then:
- Run
npx convex dev --once, and follow the steps to provision a Convex backend - Generate private and public key by running
node generateKeys.mjs- Paste the private key to the
.env.localfile - Paste the public key to your Convex dashboard, which you can open by
running
npx convex dashboard
- Paste the private key to the
- Generate a random secret (via
openssl rand -base64 33ornpx auth secret) and save it asAUTH_SECRETto the.env.localfile - Generate another random secret and save it as
CONVEX_AUTH_ADAPTER_SECRETto- the
.env.localfile - to your Convex dashboard
- the
- Follow
this guide
to create a GitHub OAuth app and then add
AUTH_GITHUB_IDandAUTH_GITHUB_SECRETto.env.local - Follow
this guide
to sign up for Resend and then add
AUTH_RESEND_KEYto.env.local
Now your .env.local should match .env.example and there should be JWKS and
CONVEX_AUTH_ADAPTER_SECRET variables on your Convex dashboard.
You can now run:
npm run devand open your app at http://localhost:3000
See Convex docs at https://docs.convex.dev/home