Welcome to Nebutra Sailor Docs 🎉
ChangelogIntroductionLicensing
Help Center (External) ↗

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

VariableRequiredDefaultDescription
DATABASE_URLYes—Full PostgreSQL connection string. Format: postgresql://user:pass@host:5432/nebutra
DATABASE_URL=postgresql://postgres:password@localhost:5432/nebutra

For 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.

VariableRequiredDefaultDescription
AUTH_PROVIDERNobetter-authServer-side auth provider. better-auth is the only real option (or dev, the local fallback).
NEXT_PUBLIC_AUTH_PROVIDERNobetter-authClient-visible auth provider. Keep this aligned with AUTH_PROVIDER.
BETTER_AUTH_SECRETFor 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_URLFor a live auth backend—Auth-center origin that serves /api/auth/*. Production: https://auth.nebutra.com.
NEXT_PUBLIC_AUTH_URLIf split auth-center—Public auth-center URL for client redirects / SDK baseURL. Usually same as BETTER_AUTH_URL.
AUTH_COOKIE_DOMAINProduction multi-subdomain—Shared cookie parent domain (e.g. .nebutra.com) so session works on app + auth.
SERVICE_SECRETYes (gateway / S2S)—HS256 secret for internal x-service-token JWTs. Not an end-user session secret.
AUTH_SSO_DISCOVERY_PROVIDERSIf 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_IDIf Feishu/Lark SSO is enabled—Feishu/Lark app id for Better Auth generic OAuth.
FEISHU_APP_SECRETIf Feishu/Lark SSO is enabled—Feishu/Lark app secret. Never expose this as NEXT_PUBLIC_.
FEISHU_OAUTH_SCOPESNocontact:user.email contact:user.base:readonlySpace- or comma-separated OAuth scopes requested from Feishu/Lark.
FEISHU_ALLOWED_TENANT_KEYSNo—Optional allowlist of Feishu tenant keys accepted by this deployment.
FEISHU_REDIRECT_URINo—Optional override. Default Better Auth callback is /api/auth/callback/feishu.
GOOGLE_CLIENT_IDIf Google OAuth is enabled—Google OAuth web client id for Better Auth.
GOOGLE_CLIENT_SECRETIf Google OAuth is enabled—Google OAuth web client secret for Better Auth.
GITHUB_CLIENT_IDIf GitHub OAuth is enabled—GitHub OAuth app client id (Better Auth).
GITHUB_CLIENT_SECRETIf GitHub OAuth is enabled—GitHub OAuth app client secret.
NEXT_PUBLIC_GOOGLE_CLIENT_IDIf Google One Tap is enabled—Public Google OAuth web client id used by the landing page One Tap prompt.
NEXT_PUBLIC_ENABLE_GOOGLE_ONE_TAPNotrueSet to false to disable the landing One Tap prompt.
NEXT_PUBLIC_TURNSTILE_SITE_KEYIf Turnstile captcha is shown—Cloudflare Turnstile site key on auth-center forms.
TURNSTILE_SECRET_KEY / TURNSTILE_SECRETIf Turnstile is enforced—Server secret for siteverify. When unset, verification is skipped.
NEXT_PUBLIC_AUTH_MAGIC_LINKNooffSet 1 / true to show magic-link alternate on auth-center sign-in.
NEXT_PUBLIC_AUTH_PASSKEYSNooffSet 1 / true to show passkey button + conditional UI.
PASSKEY_RP_IDNoauth hostnameWebAuthn RP ID override (defaults to auth-center host).
PASSKEY_ORIGINNoauth originWebAuthn origin override (defaults to auth-center origin).
NEBUTRA_LANDING_ORIGINIf landing-page One Tap is enabled—Landing origin allowed to POST to /api/auth/google-one-tap.
NEBUTRA_SESSION_HINT_DOMAINNo—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.com
AUTH_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.com
AUTH_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

VariableRequiredDefaultDescription
NEXT_PUBLIC_APP_URLYes—Base URL of the authenticated dashboard. Example: https://app.nebutra.com
NEXT_PUBLIC_API_URLYes—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.

VariableRequiredDefaultDescription
CREEM_API_KEYFor Creem checkout—Creem API key.
CREEM_PRODUCT_IDFor Creem checkout—The one-time product every checkout opens against (custom_price overrides the price per checkout).
CREEM_WEBHOOK_SECRETFor webhook verification—Signs creem-signature — the hex HMAC-SHA256 of the raw webhook body.
CREEM_TEST_MODENofalsetrue 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.

VariableRequiredDefaultDescription
STRIPE_SECRET_KEYFor subscriptions/legacy checkout—Stripe secret key. Starts with sk_live_ or sk_test_.
STRIPE_WEBHOOK_SECRETFor subscriptions/legacy checkout—Signing secret for Stripe webhook payloads. Starts with whsec_.
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYFor subscriptions/legacy checkout—Stripe publishable key. Starts with pk_live_ or pk_test_.
STRIPE_PRO_PRICE_IDFor subscriptions—Stripe Price ID for the Pro plan. Starts with price_.
STRIPE_ENTERPRISE_PRICE_IDFor 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)

VariableRequiredDefaultDescription
RESEND_API_KEYYes—Resend API key. Starts with re_.
EMAIL_FROMYes—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.

VariableRequiredDefaultDescription
UPLOAD_PROVIDERNoauto-detecteds3 (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_KEYNo—Cloudflare R2 credentials — checked first.
R2_ENDPOINT / R2_PUBLIC_URLNo—R2 endpoint and public CDN URL overrides.
AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEYNo—AWS S3 credentials — checked if no R2 credentials are set.
AWS_REGIONNous-east-1AWS region for S3.
S3_ENDPOINT / S3_PUBLIC_URLNo—Custom S3-compatible endpoint (Aliyun OSS, MinIO, …) and its public URL.
S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEYNo—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

VariableRequiredDefaultDescription
OPENAI_API_KEYNo—OpenAI API key. Required when FEATURE_AI_CHAT=true or FEATURE_AI_EMBEDDINGS=true.
OPENROUTER_API_KEYNo—OpenRouter API key. Alternative to direct OpenAI access.
AI_DEFAULT_MODELNogpt-5.4-miniDefault model identifier used for AI completions.

Redis

VariableRequiredDefaultDescription
UPSTASH_REDIS_REST_URL / UPSTASH_REDIS_REST_TOKENNo—Redis via the Upstash REST protocol — the production cache path. Checked first.
REDIS_URLNo—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)

VariableRequiredDefaultDescription
CLICKHOUSE_URLNohttp://localhost:8123ClickHouse HTTP endpoint. Required for the @nebutra/metering pipeline.
CLICKHOUSE_DBNonebutraClickHouse database name.

Error Tracking (Sentry)

VariableRequiredDefaultDescription
SENTRY_DSNNo—Sentry DSN for server-side error reporting.
NEXT_PUBLIC_SENTRY_DSNNo—Sentry DSN for client-side error reporting.

Product Analytics (PostHog)

VariableRequiredDefaultDescription
POSTHOG_KEYNo—Server-side PostHog project API key for product events. Starts with phc_.
POSTHOG_HOSTNohttps://us.i.posthog.comServer-side PostHog ingestion host.
NEXT_PUBLIC_POSTHOG_KEYNo—PostHog project API key. Starts with phc_.
NEXT_PUBLIC_POSTHOG_HOSTNohttps://app.posthog.comPostHog ingestion host. Override to use a self-hosted or EU instance.

Background Jobs (Inngest)

VariableRequiredDefaultDescription
INNGEST_EVENT_KEYNo—Inngest event API key for sending events.
INNGEST_SIGNING_KEYNo—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.

VariableRequiredDefaultDescription
QSTASH_TOKENFor a live queue—Upstash QStash REST token.
QSTASH_CURRENT_SIGNING_KEYFor a live queue—Current webhook signing key for payload verification.
QSTASH_NEXT_SIGNING_KEYFor a live queue—Next signing key, used during key rotation.
QSTASH_CALLBACK_BASE_URLFor 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 32

Use 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?

Edit on GitHub

Last updated on

On this page

Validation
Database
Authentication
Application URLs
Payments (Creem — current card rail)
Payments (Stripe — legacy, subscriptions)
Email (Resend)
Storage
AI
Redis
Analytics & Observability (ClickHouse)
Error Tracking (Sentry)
Product Analytics (PostHog)
Background Jobs (Inngest)
Queue (QStash)
Generating secrets
Related