Skip to main content

Environment variables

Available from v2.1.2.

Remotion supports environment variables being passed directly from the CLI, using a .env file and from the renderFrames() 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:

bash
REMOTION_MY_VAR=hello_world npm start
bash
REMOTION_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

.env
ini
MY_VAR=hello
ANOTHER_VAR=world
.env
ini
MY_VAR=hello
ANOTHER_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 renderFrames()#

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 renderFrames().

See also#