Environment variables
Available from v2.1.2.
Remotion supports environment variables being passed directly from the CLI, using a .env file and from the renderMedia() function.
Passing variables from the CLI
If you want to pass an environment variable from the CLI, you need to prefix it with REMOTION_. This is a security feature to prevent your whole environment which could contain sensitive information being included in a Webpack bundle.
You can pass environment variables in development mode and while rendering. For example:
bashREMOTION_MY_VAR=hello_world npm start
bashREMOTION_MY_VAR=hello_world npm start
In your project, you can access the variable using process.env.REMOTION_MY_VAR.
Using a dotenv file
Dotenv support is built in. Simply place a .env file in the root of your project and place key-value pairs in it.
For example, if your file contains
.enviniMY_VAR=helloANOTHER_VAR=world
.enviniMY_VAR=helloANOTHER_VAR=world
in your project you can read process.env to get an object {"MY_VAR": "hello", "ANOTHER_VAR": "world"}.
You can override the location of your dotenv file using the configuration file setting or the CLI flag.
Setting via renderMedia()
The above two methods only work when rendering from the CLI. To pass environment variables while server-side-rendering, pass an object to the envVariables option of renderMedia().