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

Environment variables

Every variable in the Next.js + Convex starter, split between the web env file, the admin env file and the Convex deployment.

This kit keeps configuration in three places. The web app reads apps/web/.env.local, the admin app reads apps/admin/.env.local, and everything that Convex functions need lives as deployment environment variables, set with pnpm exec convex env set NAME value from the repository root. A frontend env file never configures the backend.

Variables prefixed NEXT_PUBLIC_ are bundled into the browser. Everything else is server-only. Use placeholders below; never commit real values.

Values written by the local bootstrap

pnpm dev runs scripts/bootstrap-convex-local.ts, which writes these into the two app env files and keeps your other entries. In production you set them on each host yourself.

VariableFileRequiredPurposeWhere the value comes from
NEXT_PUBLIC_CONVEX_URLboth appsYesBrowser and server connection to Convex. The Convex client provider throws without itLocal: CONVEX_URL from the CLI-generated root .env.local. Cloud: the deployment URL (https://<name>.convex.cloud)
CONVEX_SITE_URLboth appsYes for webHTTP action origin of the deployment, also used as the Convex Auth issuer domain in auth.config.tsLocal: root .env.local. Cloud: https://<name>.convex.site
CONVEX_DEPLOYMENTapps/web/.env.localCLI onlyTells the Convex CLI which deployment apps/database scripts targetLocal: local:... or anonymous:.... Cloud: your deployment name
NEXT_PUBLIC_SITE_URLboth appsYesPublic origin of each apphttp://localhost:3000 for web, http://localhost:3002 for admin; your domains in production
APP_ENVboth appsYes locallyMarks the local environment; the bootstrap sets localSet by the bootstrap
NEXT_PUBLIC_ADMIN_APP_URLapps/web/.env.localYesAdmin origin that the web app links to (impersonation banner, admin consent hand-off)http://localhost:3002 locally; your admin domain in production
NEXT_PUBLIC_WEB_APP_URLapps/admin/.env.localYesCustomer web origin the admin app links to, sends impersonation handoffs to and calls /api/revalidate onhttp://localhost:3000 locally; your web domain in production
REVALIDATE_SECRETboth appsYesShared secret for POST /api/revalidate on the web app. Must be identical in both appsThe bootstrap generates one and writes the same value to both files

The root .env.local (CONVEX_DEPLOYMENT, CONVEX_URL, CONVEX_SITE_URL) is generated by convex dev, is git-ignored, and is only read by the bootstrap script.

apps/web/.env.local.example

These are the entries in the example file, in order. Copy it only when apps/web/.env.local is missing. The first four are commented out in the example because the bootstrap writes them; fill them in by hand only for a cloud deployment.

VariableRequiredPurposeWhere the value comes from
APP_ENVGeneratedlocal marks the local environmentWritten by the bootstrap; unset in production
NEXT_PUBLIC_CONVEX_URLGeneratedConvex deployment URLWritten by the bootstrap; https://<name>.convex.cloud in production
CONVEX_SITE_URLGeneratedConvex HTTP actions originWritten by the bootstrap; https://<name>.convex.site in production
CONVEX_DEPLOYMENTGenerated, CLI onlyDeployment the Convex CLI targetsWritten by the bootstrap; local:... or anonymous:... locally
NEXT_PUBLIC_SITE_URLYesWebsite origin (also written by the bootstrap)http://localhost:3000
NEXT_PUBLIC_SUPABASE_URLLegacyPlaceholder read by remaining Supabase-era code paths under apps/web/src and by next build. Convex does not use itKeep the placeholder from the example; do not point it at a project
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYLegacySame as abovePlaceholder
SUPABASE_SECRET_KEYLegacySame as above, server-onlyPlaceholder
SUPABASE_DATABASE_PASSWORDLegacyUnused by ConvexPlaceholder
SUPABASE_PROJECT_REFLegacy, commented outUnused by ConvexLeave commented
STRIPE_SECRET_KEYOptionalStripe API access in apps/web/src/payments/ and /api/stripe/webhooksStripe dashboard
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYOptionalStripe.js in the browserStripe dashboard
STRIPE_WEBHOOK_SECRETOptionalVerifies webhook signaturesstripe listen locally, webhook settings in production
ADMIN_EMAILYes for app emailsfrom address for emails the Next.js server sends (invitations, account emails)An address verified with your email provider
RESEND_API_KEYProductionResend key for emails sent by the Next.js server. Separate from the backend's AUTH_RESEND_KEYResend dashboard
USE_LOCAL_EMAILOptionaltrue posts to a Mailpit server at http://localhost:54324, which this kit does not starttrue or unset
NEXT_PUBLIC_POSTHOG_API_KEYOptionalPostHog analyticsPostHog project settings
NEXT_PUBLIC_POSTHOG_APP_IDOptionalPostHogPostHog project settings
NEXT_PUBLIC_POSTHOG_HOSTOptionalPostHog ingestion hostPostHog project settings
NEXT_PUBLIC_GA_IDOptionalGoogle AnalyticsGoogle Analytics property
UNKEY_ROOT_KEYOptionalUnkey API key management (src/data/user/unkey.ts)Unkey dashboard
UNKEY_API_IDOptionalUnkey API idUnkey dashboard
TWITTER_API_KEY, TWITTER_API_SECRETLegacySupabase-era social provider keys. Convex Auth never reads themLeave as placeholders
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETLegacyNot read by Convex Auth; use AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET on the backend insteadLeave as placeholders
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRETLegacyNot read by Convex Auth; use AUTH_GITHUB_ID and AUTH_GITHUB_SECRET on the backend insteadLeave as placeholders
REVALIDATE_SECRETYesRequired in the x-revalidate-secret header for POST /api/revalidate; the admin app sends it after publishing contentThe bootstrap generates one and keeps the same value in apps/admin/.env.local
OTEL_ENABLEDOptionalTurns on OpenTelemetry in instrumentation.tstrue or false
OTEL_SERVICE_NAMEOptionalService name for tracesDefault nextbase-ultimate-web
OTEL_EXPORTER_OTLP_ENDPOINTOptionalOTLP collector endpointYour collector, default http://localhost:4318
OTEL_EXPORTER_OTLP_HEADERSOptionalExtra OTLP headersYour collector
LOG_LEVELOptionalStructured logger verbosityinfo by default
NEXT_PUBLIC_ADMIN_APP_URLYesOrigin of the separate admin app (also written by the bootstrap)http://localhost:3002

Two variables are read by the code but are not in the example: NEXT_PUBLIC_SENTRY_DSN (Sentry client, server and edge configs) and OPENAI_API_KEY (the /api/chat route and image generation; it appears in apps/web/.env.test). Add them to apps/web/.env.local if you enable those features.

apps/admin/.env.local.example

The admin app has its own, much shorter example. The bootstrap writes apps/admin/.env.local for you locally.

VariableRequiredPurposeWhere the value comes from
NEXT_PUBLIC_SITE_URLYesThe admin app's own originhttp://localhost:3002 locally; your admin domain in production
NEXT_PUBLIC_WEB_APP_URLYesThe customer web origin: links back to the web app, the impersonation destination and the /api/revalidate targethttp://localhost:3000 locally; your web domain in production
NEXT_PUBLIC_CONVEX_URLYesConvex deployment URL, the same value as the web apphttps://<name>.convex.cloud
NEXT_PUBLIC_CONVEX_SITE_URLListedConvex HTTP actions origin. Listed in the example; the admin code does not currently read it, and the bootstrap writes CONVEX_SITE_URL insteadhttps://<name>.convex.site
REVALIDATE_SECRETYesMust match the web app's value; safe-action.ts refuses to revalidate without it and NEXT_PUBLIC_WEB_APP_URLSame value as apps/web/.env.local

The admin code also reads ADMIN_EMAIL, RESEND_API_KEY, USE_LOCAL_EMAIL, the STRIPE_* keys and the legacy Supabase placeholders from its environment; they are not in its example file. Add them to apps/admin/.env.local if a feature or build needs them.

Convex deployment variables

Set these with the CLI against the deployment you have selected. The local bootstrap sets JWT_PRIVATE_KEY, JWKS, SITE_URL, ADMIN_SITE_URL and APP_ENV for you.

pnpm exec convex env set SITE_URL https://example.com
pnpm exec convex env set ADMIN_SITE_URL https://admin.example.com
pnpm exec convex env set AUTH_RESEND_KEY re_xxx
pnpm exec convex env set AUTH_EMAIL_FROM "Nextbase <auth@example.com>"
pnpm exec convex env set MCP_APP_URL https://example.com
VariableRequiredPurposeWhere the value comes from
JWT_PRIVATE_KEYYesConvex Auth signing key (RS256, PKCS8)Generated by the bootstrap locally. For a cloud deployment, generate your own pair
JWKSYesPublic JWKS matching JWT_PRIVATE_KEYSame as above
SITE_URLYesWebsite origin. Validates auth redirects (lib/auth_redirect.ts), builds password reset links, and is the last fallback for the MCP consent URLYour website origin
ADMIN_SITE_URLYes with the admin appAdmin origin. Added to the auth redirect allowlist so admin login and magic-link callbacks return to the admin app, and used as the consent page origin for the Admin MCPYour admin origin
APP_ENVYes locallylocal or test makes auth emails log to the console instead of sendinglocal from the bootstrap; unset in production
AUTH_RESEND_KEYProductionResend key used by convex/auth.ts for verification, magic link and password reset emailsResend dashboard
AUTH_EMAIL_FROMProductionSender for those emailsA sender on your verified Resend domain
AUTH_GITHUB_ID, AUTH_GITHUB_SECRETOptionalRegisters the GitHub provider when both existGitHub OAuth app
AUTH_GOOGLE_ID, AUTH_GOOGLE_SECRETOptionalRegisters the Google provider when both existGoogle Cloud OAuth client
MCP_APP_URLProductionCanonical website origin used for the User MCP consent redirect and the browser origin allowlist. Falls back to APP_URL, then SITE_URLYour website origin
CONVEX_SITE_URLSuppliedThe deployment's .convex.site origin. Convex provides it; the MCP code throws if it is missingProvided by Convex

The bootstrap refuses to run against a deployment whose name does not start with local: or anonymous:, so it cannot write these to a shared environment by accident.

For how the auth variables are used, see authentication. For production, see deployment.

Installation

Clone the Next.js + Convex starter, start the local Convex backend with pnpm dev, and create your first account, workspace and administrator.

Authentication

How Convex Auth works in the Next.js + Convex starter: providers, sessions, the admin app and role, and how functions are protected.

On this page

Values written by the local bootstrapapps/web/.env.local.exampleapps/admin/.env.local.exampleConvex deployment variables