Banata

Configuration

Self-Hosted Environment Variables

Complete reference for every environment variable used by Banata Auth — Convex backend, Next.js frontend, and OAuth providers.

This page applies to the self-hosted Convex + Next.js architecture.

If you use Banata as a managed service, start in the dashboard, create a project, issue a project-scoped API key, and use @banata-auth/sdk. You do not need this Convex deployment setup for the dashboard-first path.

Banata Auth uses environment variables in two separate runtimes for self-hosting: the Convex backend (server-side) and the Next.js frontend. It's important to set each variable in the right place.


Quick Reference

VariableWhere to SetRequiredDescription
BETTER_AUTH_SECRETConvexYesSigns sessions, tokens, and webhooks
SITE_URLConvexYesYour app's public URL
CONVEX_DEPLOYMENT.env.localYesConvex deployment name
NEXT_PUBLIC_CONVEX_URL.env.localYesConvex client URL
NEXT_PUBLIC_CONVEX_SITE_URL.env.localYesConvex HTTP actions URL
NEXT_PUBLIC_SITE_URL.env.localRecommendedApp URL for build-time prerendering
OAuth credentialsConvexIf using social authProvider-specific client ID and secret
RESEND_API_KEYConvexIf sending emailsResend API key

Convex Environment Variables

These are set on the Convex deployment using npx convex env set. They're available to Convex functions via process.env.

Core

VariableRequiredDefaultDescription
BETTER_AUTH_SECRETYesCryptographic secret for signing sessions, tokens, and webhook payloads. Must be a strong random string (32+ bytes). Generate with openssl rand -base64 32.
SITE_URLYesYour app's public URL (e.g., http://localhost:3000 in dev, https://myapp.com in production). Used for OAuth callback URLs, email links, and cookie configuration.
bash
# Set core variables
npx convex env set BETTER_AUTH_SECRET "$(openssl rand -base64 32)"
npx convex env set SITE_URL "http://localhost:3000"

Social OAuth Providers

Set these only for the providers you've enabled in socialProviders:

VariableProviderDescription
GOOGLE_CLIENT_IDGoogleOAuth 2.0 client ID from Google Cloud Console
GOOGLE_CLIENT_SECRETGoogleOAuth 2.0 client secret
GITHUB_CLIENT_IDGitHubOAuth App client ID from GitHub Developer Settings
GITHUB_CLIENT_SECRETGitHubOAuth App client secret
APPLE_CLIENT_IDAppleServices ID from Apple Developer Portal
APPLE_CLIENT_SECRETAppleGenerated JWT client secret (expires every 6 months)
MICROSOFT_CLIENT_IDMicrosoftApplication (client) ID from Azure Portal
MICROSOFT_CLIENT_SECRETMicrosoftClient secret value from Azure Portal
MICROSOFT_TENANT_IDMicrosoftDirectory (tenant) ID, or "common", "organizations", "consumers"
FACEBOOK_CLIENT_IDFacebookApp ID from Meta for Developers
FACEBOOK_CLIENT_SECRETFacebookApp Secret from Meta for Developers
TWITTER_CLIENT_IDTwitter/XOAuth 2.0 Client ID
TWITTER_CLIENT_SECRETTwitter/XOAuth 2.0 Client Secret
DISCORD_CLIENT_IDDiscordApplication Client ID
DISCORD_CLIENT_SECRETDiscordApplication Client Secret
SPOTIFY_CLIENT_IDSpotifyApp Client ID
SPOTIFY_CLIENT_SECRETSpotifyApp Client Secret
TWITCH_CLIENT_IDTwitchApplication Client ID
TWITCH_CLIENT_SECRETTwitchApplication Client Secret
LINKEDIN_CLIENT_IDLinkedInApp Client ID
LINKEDIN_CLIENT_SECRETLinkedInApp Client Secret
bash
# Example: Set GitHub OAuth credentials
npx convex env set GITHUB_CLIENT_ID "Ov23li..."
npx convex env set GITHUB_CLIENT_SECRET "your-secret"
 
# Example: Set Google OAuth credentials
npx convex env set GOOGLE_CLIENT_ID "123456.apps.googleusercontent.com"
npx convex env set GOOGLE_CLIENT_SECRET "GOCSPX-..."

Email Provider

VariableRequiredDescription
RESEND_API_KEYIf sending emailsAPI key from Resend. Used in email callbacks for verification, password reset, magic links, OTP, and invitations.
bash
npx convex env set RESEND_API_KEY "re_..."

Note: You can use any email provider (SendGrid, Postmark, Mailgun, etc.) — just change the fetch() call in your email callbacks. RESEND_API_KEY is shown here because the dashboard uses Resend by default.

Passkey (WebAuthn)

VariableRequiredDescription
PASSKEY_RP_IDIf using passkeysRelying Party ID (e.g., "localhost" in dev, "myapp.com" in production)
PASSKEY_ORIGINIf using passkeysOrigin URL (e.g., "http://localhost:3000" in dev)
bash
npx convex env set PASSKEY_RP_ID "myapp.com"
npx convex env set PASSKEY_ORIGIN "https://myapp.com"

Listing All Convex Variables

bash
# View all set variables
npx convex env list
 
# Remove a variable
npx convex env unset GITHUB_CLIENT_ID

Next.js Environment Variables (.env.local)

These are set in your .env.local file and are available to your Next.js app.

Core

VariableRequiredPublic?Description
CONVEX_DEPLOYMENTYesNoConvex deployment identifier (e.g., dev:your-project-name)
NEXT_PUBLIC_CONVEX_URLYesYesConvex client URL (e.g., https://your-project.convex.cloud)
NEXT_PUBLIC_CONVEX_SITE_URLYesYesConvex HTTP actions URL (e.g., https://your-project.convex.site)
NEXT_PUBLIC_SITE_URLRecommendedYesYour app's URL. Used for building absolute URLs during SSR.

Example .env.local

bash
# Convex deployment
CONVEX_DEPLOYMENT=dev:your-deployment-name
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
NEXT_PUBLIC_CONVEX_SITE_URL=https://your-deployment.convex.site
 
# App URL
NEXT_PUBLIC_SITE_URL=http://localhost:3000

Local Development

For local Convex development (npx convex dev):

bash
CONVEX_DEPLOYMENT=local:local-your-project-name
NEXT_PUBLIC_CONVEX_URL=http://127.0.0.1:3210
NEXT_PUBLIC_CONVEX_SITE_URL=http://127.0.0.1:3211
NEXT_PUBLIC_SITE_URL=http://localhost:3000

NEXT_PUBLIC_ Prefix

Variables starting with NEXT_PUBLIC_ are embedded in the client-side JavaScript bundle and visible to users. Never put secrets in NEXT_PUBLIC_ variables.

Safe for NEXT_PUBLIC_Not Safe for NEXT_PUBLIC_
Convex URLBETTER_AUTH_SECRET
Site URLAPI keys
Feature flagsOAuth secrets

Dashboard-Specific Variables

The admin dashboard (apps/dashboard) uses additional variables:

VariableWhereDescription
RESEND_API_KEYConvexFor sending auth emails from the dashboard
BETTER_AUTH_SECRETConvexDashboard auth secret (can be different from your app's)
SITE_URLConvexDashboard URL (e.g., http://localhost:3000)

Production Checklist

Before deploying to production, verify:

  • BETTER_AUTH_SECRET is set to a unique, strong random value (different from development)
  • SITE_URL is set to your production domain (e.g., https://myapp.com)
  • NEXT_PUBLIC_CONVEX_URL points to your production Convex deployment
  • NEXT_PUBLIC_CONVEX_SITE_URL points to your production Convex site URL
  • OAuth callback URLs in provider dashboards are updated to production URLs
  • PASSKEY_RP_ID is set to your production domain (not localhost)
  • PASSKEY_ORIGIN is set to your production origin (with https://)
  • Email provider API key is set and verified
  • No development secrets are used in production
  • .env.local is in .gitignore (never commit secrets)

Template .env.local

Copy this template for new projects:

bash
# Convex deployment (filled by `npx convex dev`)
CONVEX_DEPLOYMENT=dev:your-deployment-name
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud
NEXT_PUBLIC_CONVEX_SITE_URL=https://your-deployment.convex.site
 
# App URL
NEXT_PUBLIC_SITE_URL=http://localhost:3000

And set these on Convex:

bash
npx convex env set BETTER_AUTH_SECRET "$(openssl rand -base64 32)"
npx convex env set SITE_URL "http://localhost:3000"
# Add OAuth and email provider secrets as needed

What's Next

  • Deploy — Production deployment guide
  • Quick Start — Set up a new project from scratch
  • Convex — Backend configuration reference