Firebolt has built-in support for environment variables using .env files.

Private Variables

All code that runs on the server such as server streaming including handlers, loaders and actions have full access to all environment variables through the process.env global, eg process.env.DB_URI.

Public Variables

To use environment variables on the client (i.e. inside routes and components) environment variables must be prefixed with PUBLIC_, eg process.env.PUBLIC_DSN.

You can also change this prefix in your firebolt.config.js file.

Best Practice

  • Create a .env.example file with good development defaults, and commit this to your repository
  • Developers copy this file to .env and configure it as they need (this file is gitignored so that it isn't committed accidentally)

For more control you can also use .env.development and .env.production files. The former is used when running npm run dev and the latter is used when running npm run build and npm run start.