Nextbase Docs
Nextbase Docs
HomeBlogWelcome to Nextbase v5!Choose your starterGetting startedLocal Supabase per agent
TanStack + ConvexInstallationEnvironment variablesAuthenticationAgent connectionsProject structureDeployment
AuthenticationWorkspaces and the admin area
Building with agentsEmails with Resend
TroubleshootingNextbase v5
The 8 starter kitsTanStack + Convex

Environment variables

Every variable in the starter's two example env files, which runtime reads it, and where its value comes from.

The kit has two example files: .env.local.example at the repository root (Convex CLI and the web app) and apps/admin/.env.local.example (the admin app). Three different places read these variables, and that is the main thing to get right.

  • Web browser bundle (public): variables prefixed VITE_ in the root .env.local are inlined into the web bundle by Vite at build time, because apps/web/vite.config.ts sets envDir: "../..". Never put a secret in a VITE_ variable.
  • Admin browser bundle (public): the admin app reads its own apps/admin/.env.local (envDir: "."). The root file does not reach it.
  • Convex deployment (server-only): everything without a VITE_ prefix is read by Convex functions with process.env. A value in .env.local does not reach the backend. Set it in the selected deployment with pnpm convex env set NAME value, or in the Convex dashboard.

Both .env.local files are gitignored. In the root file, CONVEX_DEPLOYMENT, VITE_CONVEX_URL and CONVEX_SITE_URL are maintained by pnpm db:local:select (or pnpm convex deployment select); everything else is yours. If the CLI creates the file from scratch it writes CONVEX_URL instead of VITE_CONVEX_URL, so copy the example first (see installation).

Placeholders only

The values in the example files (re_example, sk_test_example, whsec_example, admin@example.com) are placeholders. Replace them with your own and never commit real keys.

Deployment selection and URLs

VariableWhere it is readRequiredPurposeWhere to get the value
CONVEX_DEPLOYMENTConvex CLI, dev:local guardRequiredSelected deployment, for example local:nextbase or prod:<name>Written by pnpm db:local:select or pnpm convex deployment select
VITE_CONVEX_URLWeb browser, dev:local guardRequiredConvex functions URL the web app connects tohttp://127.0.0.1:3210 locally; https://<name>.convex.cloud in production (Convex dashboard, Settings > URL & Deploy Key). Written by the CLI when the line already exists
CONVEX_SITE_URLConvex deploymentRequiredOrigin of HTTP actions, including /mcp/*, /oauth/* and /api/*; also used by auth.config.ts as the JWT domainhttp://127.0.0.1:3211 locally; https://<name>.convex.site in production. Convex supplies it in cloud deployments
APP_URLConvex deploymentRequiredPublic origin of the web app, used to build links in app emails and as a fallback consent-page origin for MCPhttp://localhost:3000 locally; your HTTPS origin in production. Must be an absolute URL without credentials, HTTPS outside localhost. Never generated

Authentication and email

VariableWhere it is readRequiredPurposeWhere to get the value
NEXTBASE_ADMIN_EMAILConvex deploymentRequired for adminThe one signed-in account allowed to claim platform admin on the admin app's /app-adminYour own address
AUTH_RESEND_KEYConvex deploymentNeeded for sign-upResend API key used by Convex Auth for verification codes, password reset and magic links. Sign-up cannot complete without itResend dashboard
AUTH_EMAIL_FROMConvex deploymentNeeded for sign-upSender for auth emails, for example Nextbase <auth@example.com>A verified Resend domain
RESEND_API_KEYConvex deploymentOptionalDedicated key for app emails (invitations, email change codes, deletion confirmation). Falls back to AUTH_RESEND_KEYResend dashboard
EMAIL_FROMConvex deploymentOptionalSender for app emails. Falls back to AUTH_EMAIL_FROMA verified Resend domain
EMAIL_CHANGE_SECRETConvex deploymentRequiredHashes email-change verification codesGenerate at least 32 random characters
SITE_URLConvex deploymentSet by auth:setupConvex Auth's site URL (the web origin): the first allowed redirect origin, the base for password reset links and a consent-page fallbackWritten by pnpm auth:setup; set it to your production web origin when deploying
ADMIN_SITE_URLConvex deploymentRequired for the admin appOrigin of the admin app. Added to the auth redirect allowlist so admin login, OAuth and magic link callbacks return to the admin origin; admin MCP consent is routed herehttp://localhost:3002 locally; your admin HTTPS origin in production. Listed as a comment in the root example
JWT_PRIVATE_KEY, JWKSConvex deploymentSet by auth:setupConvex Auth signing keysGenerated by pnpm auth:setup. Not in the example file; never paste them into a frontend env

Social login

VariableWhere it is readRequiredPurposeWhere to get the value
VITE_OAUTH_PROVIDERSWeb browser, admin browserOptionalComma-separated list of buttons to show: google,github,twitter. Providers not listed are hidden. Set it in both env files if the admin app should show the buttons tooYour choice
AUTH_GOOGLE_ID, AUTH_GOOGLE_SECRETConvex deploymentOptionalGoogle OAuth credentialsGoogle Cloud console
AUTH_GITHUB_ID, AUTH_GITHUB_SECRETConvex deploymentOptionalGitHub OAuth credentialsGitHub developer settings
AUTH_TWITTER_ID, AUTH_TWITTER_SECRETConvex deploymentOptionalTwitter OAuth credentialsTwitter developer portal

Showing a button with VITE_OAUTH_PROVIDERS does not configure the provider. Its AUTH_* credentials must be set in the deployment too.

Billing, AI and analytics

VariableWhere it is readRequiredPurposeWhere to get the value
STRIPE_SECRET_KEYConvex deploymentOptionalStripe API access for billingStripe dashboard
STRIPE_WEBHOOK_SECRETConvex deploymentOptionalVerifies signatures on POST /api/stripe/webhookStripe webhook endpoint settings
OPENAI_API_KEYConvex deploymentOptionalUpstream key for POST /api/ai/streamOpenAI dashboard
OPENAI_ALLOWED_MODELSConvex deploymentOptionalComma-separated allowlist for the streaming endpoint; defaults to gpt-5-miniYour choice
VITE_POSTHOG_KEYWeb browserOptionalEnables PostHog capture; leave unset to disablePostHog project settings
VITE_POSTHOG_HOSTWeb browserOptionalPostHog host, default https://us.i.posthog.comPostHog project settings

Separate admin app and MCP

VariableWhere it is readRequiredPurposeWhere to get the value
VITE_ADMIN_APP_URLWeb browserRequiredOrigin of the admin app. The web app uses it to hand admin MCP consent requests to the admin app and to return from an impersonation sessionhttp://localhost:3002 locally; your admin origin in production
MCP_APP_URLConvex deploymentOptionalCanonical web origin for the user /mcp/authorize consent page and the MCP browser origin allowlist. Falls back to APP_URL, then SITE_URLYour web origin

Admin app file (apps/admin/.env.local.example)

VariableWhere it is readRequiredPurposeWhere to get the value
VITE_CONVEX_URLAdmin browserRequiredThe same Convex functions URL the web app useshttp://127.0.0.1:3210 locally; https://<name>.convex.cloud in production. The example ships a cloud placeholder
VITE_WEB_APP_URLAdmin browserRequiredCustomer web origin. Target of impersonation handoffs (/auth/impersonate) and the "Open web app" link. The admin app throws if it is missing when you impersonate, and requires HTTPS outside localhosthttp://localhost:3000 locally; your web origin in production
VITE_OAUTH_PROVIDERSAdmin browserOptionalSocial buttons on the admin login page, same format as the web appYour choice

Build-time variables on Vercel

turbo.json lists VITE_CONVEX_URL, VITE_OAUTH_PROVIDERS, VITE_POSTHOG_HOST, VITE_POSTHOG_KEY, VITE_WEB_APP_URL and VITE_ADMIN_APP_URL as inputs to the build task. The committed vercel.json builds the frontend only and does not run convex deploy, so set VITE_CONVEX_URL and VITE_ADMIN_APP_URL (plus any optional VITE_ values) by hand in the web Vercel project, and VITE_CONVEX_URL and VITE_WEB_APP_URL in the admin Vercel project. CONVEX_DEPLOY_KEY is only needed if you change the build command to run convex deploy. The deployment page has the details.

Installation

Run the TanStack + Convex starter locally with the Convex local backend, Convex Auth, the web app and the admin app.

Authentication

How Convex Auth works in the TanStack + Convex starter, including verification emails, social login, sessions, the separate admin app, the admin claim flow and impersonation.

On this page

Deployment selection and URLsAuthentication and emailSocial loginBilling, AI and analyticsSeparate admin app and MCPAdmin app file (apps/admin/.env.local.example)Build-time variables on Vercel