Skip to content

Commit 8cec3b7

Browse files
authored
docs: add section on using .env.production and dotenvx for environmen… (#2674)
* docs: add section on using .env.production and dotenvx for environment variables * fix: correct dotenvx API usage in documentation example
1 parent 343ba54 commit 8cec3b7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/deploy-environment-variables.mdx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,52 @@ You can now use the `client` object to make authenticated requests to Google API
234234
</Step>
235235

236236
</Steps>
237+
238+
## Using `.env.production` or dotenvx with Trigger.dev
239+
240+
Trigger.dev does not automatically load `.env.production` files or dotenvx files during deploys.
241+
To use these files in your Trigger.dev environment:
242+
243+
### Option 1 — Manually add your environment variables
244+
245+
1. Open your `.env.production` (or `.env`) file
246+
2. Copy the full contents
247+
3. Go to your Trigger.dev project → **Environment Variables**
248+
4. Click **Add variables**
249+
5. Paste the contents directly into the editor
250+
251+
Trigger.dev will automatically parse and create each key/value pair.
252+
253+
This is the simplest way to bring dotenvx or `.env.production` variables into your Trigger.dev environment.
254+
255+
### Option 2 — Sync variables automatically using `syncEnvVars`
256+
257+
If you'd prefer an automated flow, you can use the `syncEnvVars` build extension to programmatically load and return your variables:
258+
259+
```ts
260+
import { defineConfig } from "@trigger.dev/sdk";
261+
import { syncEnvVars } from "@trigger.dev/build/extensions/core";
262+
import dotenvx from "@dotenvx/dotenvx";
263+
import { readFileSync } from "fs";
264+
265+
export default defineConfig({
266+
project: "<project id>",
267+
build: {
268+
extensions: [
269+
syncEnvVars(async () => {
270+
const envContent = readFileSync(".env.production", "utf-8");
271+
const parsed = dotenvx.parse(envContent);
272+
return parsed ?? {};
273+
}),
274+
],
275+
},
276+
});
277+
```
278+
279+
This will read your .env.production file using dotenvx and sync the variables to Trigger.dev during every deploy.
280+
281+
**Summary**
282+
283+
- Trigger.dev does not automatically detect .env.production or dotenvx files
284+
- You can paste them manually into the dashboard
285+
- Or sync them automatically using a build extension

0 commit comments

Comments
 (0)