From 0f22bbfe5def2bf01d8bb9d346317a2f98affed2 Mon Sep 17 00:00:00 2001 From: Lindsey Stead Date: Wed, 12 Nov 2025 20:51:20 -0800 Subject: [PATCH 1/2] docs: add section on using .env.production and dotenvx for environment variables --- docs/deploy-environment-variables.mdx | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/deploy-environment-variables.mdx b/docs/deploy-environment-variables.mdx index f9e447036f..79b522ac43 100644 --- a/docs/deploy-environment-variables.mdx +++ b/docs/deploy-environment-variables.mdx @@ -234,3 +234,50 @@ You can now use the `client` object to make authenticated requests to Google API + +## Using `.env.production` or dotenvx with Trigger.dev + +Trigger.dev does not automatically load `.env.production` files or dotenvx files during deploys. +To use these files in your Trigger.dev environment: + +### Option 1 — Manually add your environment variables + +1. Open your `.env.production` (or `.env`) file +2. Copy the full contents +3. Go to your Trigger.dev project → **Environment Variables** +4. Click **Add variables** +5. Paste the contents directly into the editor + +Trigger.dev will automatically parse and create each key/value pair. + +This is the simplest way to bring dotenvx or `.env.production` variables into your Trigger.dev environment. + +### Option 2 — Sync variables automatically using `syncEnvVars` + +If you'd prefer an automated flow, you can use the `syncEnvVars` build extension to programmatically load and return your variables: + +```ts +import { defineConfig } from "@trigger.dev/sdk"; +import { syncEnvVars } from "@trigger.dev/build/extensions/core"; +import dotenvx from "@dotenvx/dotenvx"; + +export default defineConfig({ + project: "", + build: { + extensions: [ + syncEnvVars(async () => { + const output = await dotenvx({ env: ".env.production" }); + return output.parsed ?? {}; + }), + ], + }, +}); +``` + +This will read your .env.production file using dotenvx and sync the variables to Trigger.dev during every deploy. + +**Summary** + +- Trigger.dev does not automatically detect .env.production or dotenvx files +- You can paste them manually into the dashboard +- Or sync them automatically using a build extension \ No newline at end of file From 4a5a90273a9809f72f077a5e0fabdedf22a2a8d9 Mon Sep 17 00:00:00 2001 From: Lindsey Stead Date: Wed, 12 Nov 2025 21:59:39 -0800 Subject: [PATCH 2/2] fix: correct dotenvx API usage in documentation example --- docs/deploy-environment-variables.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/deploy-environment-variables.mdx b/docs/deploy-environment-variables.mdx index 79b522ac43..1c00c94c8c 100644 --- a/docs/deploy-environment-variables.mdx +++ b/docs/deploy-environment-variables.mdx @@ -260,14 +260,16 @@ If you'd prefer an automated flow, you can use the `syncEnvVars` build extension import { defineConfig } from "@trigger.dev/sdk"; import { syncEnvVars } from "@trigger.dev/build/extensions/core"; import dotenvx from "@dotenvx/dotenvx"; +import { readFileSync } from "fs"; export default defineConfig({ project: "", build: { extensions: [ syncEnvVars(async () => { - const output = await dotenvx({ env: ".env.production" }); - return output.parsed ?? {}; + const envContent = readFileSync(".env.production", "utf-8"); + const parsed = dotenvx.parse(envContent); + return parsed ?? {}; }), ], },