Environment Variables
Complete reference of all environment variables required to run OptStuff, organized by category.
This page documents all environment variables used by the OptStuff dashboard. Copy the .env.example file as a starting point:
cp apps/optstuff-dashboard/.env.example apps/optstuff-dashboard/.envApplication
| Variable | Required | Description | Example |
|---|---|---|---|
NEXT_PUBLIC_APP_URL | Yes | Public URL of your OptStuff deployment | https://optstuff.example.com |
NEXT_PUBLIC_DOCS_URL | Yes | URL of the documentation site | https://docs.optstuff.example.com |
Scheduling & Maintenance
| Variable | Required | Description | Example |
|---|---|---|---|
CRON_SECRET | Yes (production) | Bearer token used to authorize internal cron routes such as daily maintenance. | Generate with openssl rand -hex 32 |
Set DEMO_RESET_ENABLED=true to enable destructive demo-data resets (default: false).
DEMO_RESET_PROTECTED_USER_IDS is also required.
Set it to a comma-separated list of Clerk user IDs whose data must be retained
(for example, user_owner). Missing, empty, or malformed values disable resets.
Use IDs from the same Clerk instance as the deployment; development and
production accounts may have different IDs. Never configure a placeholder ID.
Before enabling this feature, synchronize the database schema with
pnpm --filter optstuff-dashboard db:push --strict --verbose so user_reset_cycle exists
and its nextResetAt column is nullable. Review the proposed SQL before applying
it; unrelated schema differences should be resolved separately.
Configure the protected IDs, DEMO_RESET_ENABLED=true, and CRON_SECRET in Vercel, then deploy.
Do not invoke the reset route to verify a production deployment: it deletes data.
Observability
| Variable | Required | Description | Default |
|---|---|---|---|
REQUEST_LOG_SUCCESS_SAMPLE_RATE | No | Success request log sampling rate (0.0 to 1.0). Error, policy-denied, and rate-limited logs are always recorded. | 0.2 in production, 1.0 otherwise |
Database (PostgreSQL)
The dashboard reads a single PostgreSQL connection string.
| Variable | Required | Description | Example |
|---|---|---|---|
DATABASE_URL | Yes | Primary connection string (pooled recommended) | postgresql://user:pass@host/db |
Redis (Upstash)
Redis is required for rate limiting, config caching, usage buffering, and write throttling.
| Variable | Required | Description | Example |
|---|---|---|---|
UPSTASH_REDIS_REST_URL | Yes | Upstash Redis REST endpoint | https://example.upstash.io |
UPSTASH_REDIS_REST_TOKEN | Yes | Upstash Redis REST token | AXxxxxx... |
Authentication (Clerk)
| Variable | Required | Description | Example |
|---|---|---|---|
CLERK_SECRET_KEY | Yes | Clerk server-side secret key | sk_test_xxxx... |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Yes | Clerk client-side publishable key | pk_test_xxxx... |
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL | Yes | Redirect after sign-in | /dashboard |
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL | Yes | Redirect after sign-up | /dashboard |
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL | Yes | Fallback redirect after sign-in | /dashboard |
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL | Yes | Fallback redirect after sign-up | /dashboard |
Encryption
| Variable | Required | Description | Example |
|---|---|---|---|
API_KEY_ENCRYPTION_SECRET | Yes | Master key for AES-256-GCM encryption of API secret keys. Must be 32+ characters. | Generate with openssl rand -base64 32 |
This is the most sensitive configuration value. If compromised, all stored API secret keys can be decrypted. There is no automatic rotation mechanism — rotating requires re-encrypting all keys.
Build-Time Escape Hatch
| Variable | Required | Description | Default |
|---|---|---|---|
SKIP_ENV_VALIDATION | No | Set to a truthy value only for Docker/build contexts where env validation must be deferred. Do not use for normal production runtime. | unset |
Client SDK Variables
These variables are used in your application code (not the OptStuff dashboard) to interact with the API:
| Variable | Description | Example |
|---|---|---|
OPTSTUFF_BASE_URL | OptStuff API base URL | https://optstuff.example.com |
OPTSTUFF_PROJECT_SLUG | Your project identifier | my-blog |
OPTSTUFF_PUBLIC_KEY | API public key | pk_abc123... |
OPTSTUFF_SECRET_KEY | API secret key (server-side only) | sk_... |
For integration examples using these variables, see the Next.js Integration guide.
Related Documentation
- Deployment Guide — How to deploy OptStuff
- Key Management — API key lifecycle
- Security Best Practices — Security recommendations
Last updated on