Environment Variables
Environment variables allow you to configure your application dynamically without hardcoding values. Nept supports different variables for Production, Preview, and Development environments.
Adding Variables
You can manage environment variables via the CLI or the Dashboard.
Using the CLI
# Add a variable to all environments
nept env add API_KEY 123456789
# Add a variable to production only
nept env add DATABASE_URL postgres://... --target production
# Add a variable to preview only
nept env add DEBUG true --target preview
Encrypted Secrets
For sensitive information like API keys and database credentials, Nept encrypts variables at rest. They are only decrypted at runtime within the secure sandbox.
Accessing Variables
In your code, access variables using the standard process for your language.
Node.js / Next.js:
const apiKey = process.env.API_KEY;
Python:
import os
api_key = os.environ.get('API_KEY')
Built-in Variables
Nept automatically injects a set of system variables into every deployment:
| Variable | Description |
| :--- | :--- |
| NEPT_ENV | The current environment (production, preview, development). |
| NEPT_REGION | The region where the function is executing (e.g., sfo1). |
| NEPT_URL | The unique URL for the current deployment. |
| CI | Always set to true. |
.env Files
During local development (nept dev), we load variables from your local .env file.
Warning: Never commit your
.envfile to version control. Add it to your.gitignore.
When deploying, local .env files are ignored by default to prevent accidental leaks. You must upload them using nept env add or configure them in the dashboard.