Store API keys, tokens, and secrets in Rocket.new environment variables so credentials stay out of your source code and version history.
Environment variables let you store API keys, database URLs, and other secrets without hardcoding them in your app. Rocket keeps separate values for staging (while you build) and production (when you launch).
The Environment settings panel is only available for web build tasks, which use a .env file. For mobile tasks, variables are stored in env.json - update them directly in that file or inside the connector’s value field.
New environment variables are added through your .env file in code, not through the Settings UI.
1
Open the Code tab
Click Code in the editor toolbar to open the file explorer.
2
Edit the .env file
Use placeholder values (like your-key-here) in code files. Set your real secrets only in the Environment panel. Never commit actual keys to a repository.
Open .env at the root of your project and add your variable:
To update the value of an existing variable, open the Environment panel (Settings > Environment) and click the edit icon on the right side of any variable row. Make your change and save.Changes take effect on the next build or generation in that environment.
Variables prefixed with NEXT_PUBLIC_ are exposed to the browser (client side). All others stay server-side only. Never put secrets in NEXT_PUBLIC_ variables.