Skip to content

🎥 Make videos programmatically with React

add docs

Jonny Burger1acaa091e34f
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdx
index f5ea774e87..069b2da8eb 100644
--- a/packages/docs/docs/config.mdx
+++ b/packages/docs/docs/config.mdx
@@ -142,6 +142,8 @@ Set a custom location for a [`.env`](https://www.npmjs.com/package/dotenv) file.
Config.Rendering.setDotEnvLocation('.my-env')
```
+The [command line flag](/docs/cli) `--env-file` will take precedence over this option.
+
## Output
### setOverwriteOutput()
diff --git a/packages/docs/docs/env-variables.md b/packages/docs/docs/env-variables.md
new file mode 100644
index 0000000000..c9e68d8db2
--- /dev/null
+++ b/packages/docs/docs/env-variables.md
@@ -0,0 +1,44 @@
+---
+id: env-variables
+title: Environment variables
+---
+
+_Available from v2.2._
+
+Remotion supports environment variables being passed directly from the CLI, using a `.env` file and from the [`renderFrames()`](/docs/render-frames) 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:
+
+```console
+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](https://www.npmjs.com/package/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
+
+```dotenv
+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](/docs/config#setdotenvlocation) or the [CLI flag](/docs/cli).
+
+## 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()`](/docs/render-frames#env-variables).
+
+## See also
+
+- [`renderFrames()` - envVariables](/docs/render-frames#env-variables)
+- [dotenv](https://www.npmjs.com/package/dotenv)
diff --git a/packages/docs/docs/render-frames.md b/packages/docs/docs/render-frames.md
index d94aa4d765..67ee349f9f 100644
--- a/packages/docs/docs/render-frames.md
+++ b/packages/docs/docs/render-frames.md
@@ -117,13 +117,13 @@ _optional_
An already open Puppeteer [`Browser`](https://pptr.dev/#?product=Puppeteer&version=main&show=api-class-browser) instance. Reusing a browser across multiple function calls can speed up the rendering process. You are responsible for opening and closing the browser yourself. If you don't specify this option, a new browser will be opened and closed at the end.
-### `envVariables`
+### `envVariables?`
-_optional_
+_optional - Available since v2.2.0_
An object containing key-value pairs of environment variables which will be injected into your Remotion projected and which can be accessed by reading the global `process.env` object.
-### `onError`
+### `onError?`
_optional - Available since v2.1.0_
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index a14c07a2bc..52900e6918 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -31,6 +31,7 @@ module.exports = {
"ssr",
"webpack",
"legacy-babel",
+ "env-variables",
],
},
"cli",