Environment Variables
Complete reference for every environment variable in Nebutra-Sailor — requirement level, default value, and service context.
Validation
All variables are validated by @nebutra/config at startup (packages/platform/config/src/index.ts). Required variables that are absent or empty cause an immediate, descriptive startup error. Optional variables that are absent fall back to the documented default.
Variables prefixed with NEXT_PUBLIC_ are bundled into the client-side JavaScript and are visible to end users. Never put secrets in NEXT_PUBLIC_ variables.
Database
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL | Yes | — | Full PostgreSQL connection string. Format: postgresql://user:pass@host:5432/nebutra |
DATABASE_URL=postgresql://postgres:password@localhost:5432/nebutraFor local development, pnpm infra:up starts a PostgreSQL 16 instance on port 5432 with user postgres and password password.
Authentication
Better Auth is the only auth provider — the Sailor Convergence ADR (2026-09-24) deleted the Clerk,
NextAuth, and Supabase auth adapters. Without BETTER_AUTH_SECRET set, auth degrades to a dev
fallback (nebutra status reports this as local-fallback), not to a different provider.
| Variable | Required | Default | Description |
|---|---|---|---|
AUTH_PROVIDER | No | better-auth | Server-side auth provider. better-auth is the only real option (or dev, the local fallback). |
NEXT_PUBLIC_AUTH_PROVIDER | No | better-auth | Client-visible auth provider. Keep this aligned with AUTH_PROVIDER. |
BETTER_AUTH_SECRET | For a live auth backend | — | Self-hosted Better Auth signing secret. Generate with openssl rand -base64 32. Must match on auth-center and every RP app. |
BETTER_AUTH_URL | For a live auth backend | — | Auth-center origin that serves /api/auth/*. Production: https://auth.nebutra.com. |
NEXT_PUBLIC_AUTH_URL | If split auth-center | — | Public auth-center URL for client redirects / SDK baseURL. Usually same as BETTER_AUTH_URL. |
AUTH_COOKIE_DOMAIN | Production multi-subdomain | — | Shared cookie parent domain (e.g. .nebutra.com) so session works on app + auth. |
SERVICE_SECRET | Yes (gateway / S2S) | — | HS256 secret for internal x-service-token JWTs. Not an end-user session secret. |
AUTH_SSO_DISCOVERY_PROVIDERS | If Enterprise SSO discovery is enabled | — | JSON array mapping email domains to SSO providers. Feishu entries use /api/auth/oauth/feishu; generic entries must define an internal loginUrl. |
FEISHU_APP_ID | If Feishu/Lark SSO is enabled | — | Feishu/Lark app id for Better Auth generic OAuth. |
FEISHU_APP_SECRET | If Feishu/Lark SSO is enabled | — | Feishu/Lark app secret. Never expose this as NEXT_PUBLIC_. |
FEISHU_OAUTH_SCOPES | No | contact:user.email contact:user.base:readonly | Space- or comma-separated OAuth scopes requested from Feishu/Lark. |
FEISHU_ALLOWED_TENANT_KEYS | No | — | Optional allowlist of Feishu tenant keys accepted by this deployment. |
FEISHU_REDIRECT_URI | No | — | Optional override. Default Better Auth callback is /api/auth/callback/feishu. |
GOOGLE_CLIENT_ID | If Google OAuth is enabled | — | Google OAuth web client id for Better Auth. |
GOOGLE_CLIENT_SECRET | If Google OAuth is enabled | — | Google OAuth web client secret for Better Auth. |
GITHUB_CLIENT_ID | If GitHub OAuth is enabled | — | GitHub OAuth app client id (Better Auth). |
GITHUB_CLIENT_SECRET | If GitHub OAuth is enabled | — | GitHub OAuth app client secret. |
NEXT_PUBLIC_GOOGLE_CLIENT_ID | If Google One Tap is enabled | — | Public Google OAuth web client id used by the landing page One Tap prompt. |
NEXT_PUBLIC_ENABLE_GOOGLE_ONE_TAP | No | true | Set to false to disable the landing One Tap prompt. |
NEXT_PUBLIC_TURNSTILE_SITE_KEY | If Turnstile captcha is shown | — | Cloudflare Turnstile site key on auth-center forms. |
TURNSTILE_SECRET_KEY / TURNSTILE_SECRET | If Turnstile is enforced | — | Server secret for siteverify. When unset, verification is skipped. |
NEXT_PUBLIC_AUTH_MAGIC_LINK | No | off | Set 1 / true to show magic-link alternate on auth-center sign-in. |
NEXT_PUBLIC_AUTH_PASSKEYS | No | off | Set 1 / true to show passkey button + conditional UI. |
PASSKEY_RP_ID | No | auth hostname | WebAuthn RP ID override (defaults to auth-center host). |
PASSKEY_ORIGIN | No | auth origin | WebAuthn origin override (defaults to auth-center origin). |
NEBUTRA_LANDING_ORIGIN | If landing-page One Tap is enabled | — | Landing origin allowed to POST to /api/auth/google-one-tap. |
NEBUTRA_SESSION_HINT_DOMAIN | No | — | Optional shared cookie domain for the lightweight cross-subdomain session hint. |
AUTH_PROVIDER=better-auth
NEXT_PUBLIC_AUTH_PROVIDER=better-auth
BETTER_AUTH_SECRET=local-dev-secret
BETTER_AUTH_URL=http://localhost:3101
NEXT_PUBLIC_AUTH_URL=http://localhost:3101
GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxx
NEXT_PUBLIC_GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.comAUTH_PROVIDER=better-auth
NEXT_PUBLIC_AUTH_PROVIDER=better-auth
BETTER_AUTH_SECRET=... # same on apps/auth + apps/web
BETTER_AUTH_URL=https://auth.nebutra.com
NEXT_PUBLIC_AUTH_URL=https://auth.nebutra.com
AUTH_COOKIE_DOMAIN=.nebutra.com
DATABASE_URL=postgresql://...
SERVICE_SECRET=...
GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxx
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
NEXT_PUBLIC_TURNSTILE_SITE_KEY=0x4AAAAA...
TURNSTILE_SECRET_KEY=0x4AAAAA...
# Optional UX flags on auth-center:
# NEXT_PUBLIC_AUTH_MAGIC_LINK=1
# NEXT_PUBLIC_AUTH_PASSKEYS=1
# PASSKEY_RP_ID=auth.nebutra.com
# PASSKEY_ORIGIN=https://auth.nebutra.comAUTH_PROVIDER=better-auth
NEXT_PUBLIC_AUTH_PROVIDER=better-auth
BETTER_AUTH_SECRET=...
BETTER_AUTH_URL=https://auth.nebutra.com
NEXT_PUBLIC_AUTH_URL=https://auth.nebutra.com
AUTH_COOKIE_DOMAIN=.nebutra.com
FEISHU_APP_ID=cli_xxx
FEISHU_APP_SECRET=xxx
FEISHU_OAUTH_SCOPES="contact:user.email contact:user.base:readonly"
AUTH_SSO_DISCOVERY_PROVIDERS='[{"domain":"example.cn","id":"example-feishu","name":"Example Feishu","type":"oidc","provider":"feishu"}]'OAuth redirect URIs must target the auth-center origin, e.g.
https://auth.nebutra.com/api/auth/callback/google and
https://auth.nebutra.com/api/auth/callback/github. GET https://auth.nebutra.com/health
returns the currently enabled oauth.callbackUrls.
Application URLs
| Variable | Required | Default | Description |
|---|---|---|---|
NEXT_PUBLIC_APP_URL | Yes | — | Base URL of the authenticated dashboard. Example: https://app.nebutra.com |
NEXT_PUBLIC_API_URL | Yes | — | Base URL of the API gateway. Example: https://api.nebutra.com |
Payments (Creem — current card rail)
Creem is a merchant of record (it collects and remits sales tax/VAT itself) for cards worldwide — see ADR 2026-09-26 and the Creem integration guide.
| Variable | Required | Default | Description |
|---|---|---|---|
CREEM_API_KEY | For Creem checkout | — | Creem API key. |
CREEM_PRODUCT_ID | For Creem checkout | — | The one-time product every checkout opens against (custom_price overrides the price per checkout). |
CREEM_WEBHOOK_SECRET | For webhook verification | — | Signs creem-signature — the hex HMAC-SHA256 of the raw webhook body. |
CREEM_TEST_MODE | No | false | true points requests at https://test-api.creem.io instead of https://api.creem.io. |
Payments (Stripe — legacy, subscriptions)
Stripe is retired from new work. Its env vars still feed subscriptions, the billing portal, and checkouts opened before the Creem switch — see Stripe integration.
| Variable | Required | Default | Description |
|---|---|---|---|
STRIPE_SECRET_KEY | For subscriptions/legacy checkout | — | Stripe secret key. Starts with sk_live_ or sk_test_. |
STRIPE_WEBHOOK_SECRET | For subscriptions/legacy checkout | — | Signing secret for Stripe webhook payloads. Starts with whsec_. |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | For subscriptions/legacy checkout | — | Stripe publishable key. Starts with pk_live_ or pk_test_. |
STRIPE_PRO_PRICE_ID | For subscriptions | — | Stripe Price ID for the Pro plan. Starts with price_. |
STRIPE_ENTERPRISE_PRICE_ID | For subscriptions | — | Stripe Price ID for the Enterprise plan. Starts with price_. |
Use test-mode keys (sk_test_, pk_test_, CREEM_TEST_MODE=true) in development and preview environments. Never use live-mode keys outside production.
Email (Resend)
| Variable | Required | Default | Description |
|---|---|---|---|
RESEND_API_KEY | Yes | — | Resend API key. Starts with re_. |
EMAIL_FROM | Yes | — | Sender address shown on all transactional emails. Example: Nebutra <noreply@nebutra.com> |
Storage
One S3-compatible client covers both R2 and Aliyun OSS — there is no separate provider for each.
UPLOAD_PROVIDER picks a backend explicitly; unset, the provider auto-detects from whichever
credentials are present (R2 first, then AWS, then a custom S3-compatible endpoint), falling back
to local disk.
| Variable | Required | Default | Description |
|---|---|---|---|
UPLOAD_PROVIDER | No | auto-detected | s3 (or its alias r2) forces the S3-compatible provider; unset auto-detects from the credentials below; otherwise falls back to local. |
R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY | No | — | Cloudflare R2 credentials — checked first. |
R2_ENDPOINT / R2_PUBLIC_URL | No | — | R2 endpoint and public CDN URL overrides. |
AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY | No | — | AWS S3 credentials — checked if no R2 credentials are set. |
AWS_REGION | No | us-east-1 | AWS region for S3. |
S3_ENDPOINT / S3_PUBLIC_URL | No | — | Custom S3-compatible endpoint (Aliyun OSS, MinIO, …) and its public URL. |
S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY | No | — | Fallback credential names, used only when AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY are unset and S3_ENDPOINT is set. |
With no storage credentials set at all, uploaded files are written to ./uploads on the server filesystem (nebutra status reports this as local-fallback). This is suitable for local development only — local storage is not persistent across deployments.
Vercel Blob was deleted per the Sailor Convergence ADR (2026-09-24) — there is no blob provider. Everything object-storage-shaped goes through the S3-compatible client above.
AI
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY | No | — | OpenAI API key. Required when FEATURE_AI_CHAT=true or FEATURE_AI_EMBEDDINGS=true. |
OPENROUTER_API_KEY | No | — | OpenRouter API key. Alternative to direct OpenAI access. |
AI_DEFAULT_MODEL | No | gpt-5.4-mini | Default model identifier used for AI completions. |
Redis
| Variable | Required | Default | Description |
|---|---|---|---|
UPSTASH_REDIS_REST_URL / UPSTASH_REDIS_REST_TOKEN | No | — | Redis via the Upstash REST protocol — the production cache path. Checked first. |
REDIS_URL | No | — | Direct ioredis connection string — self-hosted Redis (e.g. behind the Serverless Redis HTTP proxy). Used for caching and rate limiting when the Upstash REST vars are unset. Example: redis://localhost:6379. |
pnpm infra:up starts Redis 7 on port 6379. pnpm infra:lite starts only PostgreSQL — Redis is not included.
Analytics & Observability (ClickHouse)
| Variable | Required | Default | Description |
|---|---|---|---|
CLICKHOUSE_URL | No | http://localhost:8123 | ClickHouse HTTP endpoint. Required for the @nebutra/metering pipeline. |
CLICKHOUSE_DB | No | nebutra | ClickHouse database name. |
Error Tracking (Sentry)
| Variable | Required | Default | Description |
|---|---|---|---|
SENTRY_DSN | No | — | Sentry DSN for server-side error reporting. |
NEXT_PUBLIC_SENTRY_DSN | No | — | Sentry DSN for client-side error reporting. |
Product Analytics (PostHog)
| Variable | Required | Default | Description |
|---|---|---|---|
POSTHOG_KEY | No | — | Server-side PostHog project API key for product events. Starts with phc_. |
POSTHOG_HOST | No | https://us.i.posthog.com | Server-side PostHog ingestion host. |
NEXT_PUBLIC_POSTHOG_KEY | No | — | PostHog project API key. Starts with phc_. |
NEXT_PUBLIC_POSTHOG_HOST | No | https://app.posthog.com | PostHog ingestion host. Override to use a self-hosted or EU instance. |
Background Jobs (Inngest)
| Variable | Required | Default | Description |
|---|---|---|---|
INNGEST_EVENT_KEY | No | — | Inngest event API key for sending events. |
INNGEST_SIGNING_KEY | No | — | Inngest signing key for webhook verification. |
Queue (QStash)
QStash is the only queue backend — BullMQ was deleted per the Sailor Convergence ADR (2026-09-24).
Without QSTASH_TOKEN, the queue degrades to an in-memory fallback (nebutra status reports this
as local-fallback), not to a self-hosted broker.
| Variable | Required | Default | Description |
|---|---|---|---|
QSTASH_TOKEN | For a live queue | — | Upstash QStash REST token. |
QSTASH_CURRENT_SIGNING_KEY | For a live queue | — | Current webhook signing key for payload verification. |
QSTASH_NEXT_SIGNING_KEY | For a live queue | — | Next signing key, used during key rotation. |
QSTASH_CALLBACK_BASE_URL | For a live queue | — | Public base URL where QStash delivers webhook callbacks. Example: https://api.nebutra.com. |
Generating secrets
For any secret that requires a cryptographically random value:
openssl rand -base64 32Use a separate secret value per environment (development, preview, production). Never reuse secrets across environments.
Related
Configuration Overview
How config validation works and where to set variables per environment.
Feature Flags
Why the scaffold doesn't have a feature-flags capability.
Common Errors
Startup errors caused by missing or incorrect environment variables.
Deployment
Deploying Nebutra-Sailor and managing secrets in production.
How is this guide?
Last updated on