syncEnvVars build extension will sync env vars from another service into Trigger.dev before the deployment starts. This is useful if you are using a secret store service like Infisical or AWS Secrets Manager to store your secrets.
syncEnvVars takes an async callback function, and any env vars returned from the callback will be synced to Trigger.dev.
environment: The environment name that the task is being deployed to (e.g.production,staging, etc.)projectRef: The project ref of the Trigger.dev projectenv: The environment variables that are currently set in the Trigger.dev project
Example: Sync env vars from Infisical
In this example we’re using env vars from Infisical.trigger.config.ts
syncVercelEnvVars
ThesyncVercelEnvVars build extension syncs environment variables from your Vercel project to Trigger.dev.
You need to set the
VERCEL_ACCESS_TOKEN and VERCEL_PROJECT_ID environment variables, or pass
in the token and project ID as arguments to the syncVercelEnvVars build extension. If you’re
working with a team project, you’ll also need to set VERCEL_TEAM_ID, which can be found in your
team settings. You can find / generate the VERCEL_ACCESS_TOKEN in your Vercel
dashboard. Make sure the scope of the token covers
the project with the environment variables you want to sync.When running the build from a Vercel build environment (e.g., during a Vercel deployment), the
environment variable values will be read from
process.env instead of fetching them from the
Vercel API. This is determined by checking if the VERCEL environment variable is present. The
API is still used to determine which environment variables are configured for your project, but
the actual values come from the local environment. Reading values from process.env allows the
extension to use values that Vercel integrations (such as the Neon integration) set per preview
deployment in the “Provisioning Integrations” phase that happens just before the Vercel build
starts.If you have the Neon database Vercel integration installed and are running builds outside of the
Vercel environment, we recommend using
syncNeonEnvVars in addition to syncVercelEnvVars for your
database environment variables. This ensures that the correct database connection strings are used for your
selected environment and current branch, as syncVercelEnvVars may not accurately reflect
branch-specific database credentials when run locally.syncNeonEnvVars
ThesyncNeonEnvVars build extension syncs environment variables from your Neon database project to Trigger.dev. It automatically detects branches and builds the appropriate database connection strings for your environment.
You need to set the
NEON_ACCESS_TOKEN and NEON_PROJECT_ID environment variables, or pass them
as arguments to the syncNeonEnvVars build extension. You can generate a NEON_ACCESS_TOKEN in
your Neon dashboard.When running the build from a Vercel environment (determined by checking if the
VERCEL
environment variable is present), this extension is skipped entirely. This is because Neon’s
Vercel integration already handles environment variable synchronization in Vercel environments.If you have the Neon database Vercel integration installed and are running builds outside of the
Vercel environment, we recommend using
syncNeonEnvVars in addition to syncVercelEnvVars for your
database environment variables. This ensures that the correct database connection strings are used for your
selected environment and current branch, as syncVercelEnvVars may not accurately reflect
branch-specific database credentials when run locally.This extension is skipped for
prod environments. It is designed to sync branch-specific
database connections for preview/staging environments.DATABASE_URL- Pooled connection stringDATABASE_URL_UNPOOLED- Direct connection stringPOSTGRES_URL,POSTGRES_URL_NO_SSL,POSTGRES_URL_NON_POOLINGPOSTGRES_PRISMA_URL- Connection string optimized for PrismaPOSTGRES_HOST,POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DATABASEPGHOST,PGHOST_UNPOOLED,PGUSER,PGPASSWORD,PGDATABASE

