# Syncing environment variables from your Vercel projects

> Source: https://trigger.dev/docs/guides/examples/vercel-sync-env-vars

**Deprecated when using the Vercel integration.** If you are using the [Vercel integration](https://trigger.dev/docs/vercel-integration)
, do not use `syncVercelEnvVars` — the integration handles env var syncing natively and using both together can cause env vars to be incorrectly populated.If you are **not** using the Vercel integration, `syncVercelEnvVars` is still supported. Continue with the configuration below.

[​](https://trigger.dev/docs/guides/examples/vercel-sync-env-vars#build-configuration)

Build configuration
-------------------------------------------------------------------------------------------------------------

If you are not using the [Vercel integration](https://trigger.dev/docs/vercel-integration)
, you can sync environment variables manually by adding the `syncVercelEnvVars` build extension to your `trigger.config.ts` file. This extension will run automatically every time you deploy your Trigger.dev project.

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](https://vercel.com/account/settings/tokens)
. 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.

trigger.config.ts

    import { defineConfig } from "@trigger.dev/sdk";
    import { syncVercelEnvVars } from "@trigger.dev/build/extensions/core";
    
    export default defineConfig({
      project: "<project ref>",
      // Your other config settings...
      build: {
        // Add the syncVercelEnvVars build extension
        extensions: [\
          syncVercelEnvVars({\
            // A personal access token created in your Vercel account settings\
            // Used to authenticate API requests to Vercel\
            // Generate at: https://vercel.com/account/tokens\
            vercelAccessToken: process.env.VERCEL_ACCESS_TOKEN,\
            // The unique identifier of your Vercel project\
            // Found in Project Settings > General > Project ID\
            projectId: process.env.VERCEL_PROJECT_ID,\
            // Optional: The ID of your Vercel team\
            // Only required for team projects\
            // Found in Team Settings > General > Team ID\
            vercelTeamId: process.env.VERCEL_TEAM_ID,\
          }),\
        ],
      },
    });
    

[Build extensions](https://trigger.dev/docs/config/extensions/overview)
 allow you to hook into the build system and customize the build process or the resulting bundle and container image (in the case of deploying). You can use pre-built extensions or create your own.

[​](https://trigger.dev/docs/guides/examples/vercel-sync-env-vars#running-the-sync-operation)

Running the sync operation
---------------------------------------------------------------------------------------------------------------------------

To sync the environment variables, all you need to do is run our `deploy` command. You should see some output in the console indicating that the environment variables have been synced, and they should now be available in your Trigger.dev dashboard.

    npx trigger.dev@latest deploy
    

[​](https://trigger.dev/docs/guides/examples/vercel-sync-env-vars#learn-more-about-next-js-and-trigger-dev)

Learn more about Next.js and Trigger.dev
-------------------------------------------------------------------------------------------------------------------------------------------------------

### 

[​](https://trigger.dev/docs/guides/examples/vercel-sync-env-vars#walk-through-guides-from-development-to-deployment)

Walk-through guides from development to deployment

Next.js - setup guide
---------------------

Learn how to setup Trigger.dev with Next.js, using either the pages or app router.

Next.js - triggering tasks using webhooks
-----------------------------------------

Learn how to create a webhook handler for incoming webhooks in a Next.js app, and trigger a task from it.

### 

[​](https://trigger.dev/docs/guides/examples/vercel-sync-env-vars#task-examples)

Task examples

![fal-realtime-thumbnail](https://mintcdn.com/trigger/uys6iMwf9B_ojh8r/images/fal-realtime-thumbnail.png?fit=max&auto=format&n=uys6iMwf9B_ojh8r&q=85&s=9ac31bb57678b222a82b04055184eea0)

Fal.ai with Realtime in Next.js
-------------------------------

Generate an image from a prompt using Fal.ai and Trigger.dev Realtime.

![fal-generate-cartoon-thumbnail](https://mintcdn.com/trigger/uys6iMwf9B_ojh8r/images/fal-generate-cartoon-thumbnail.png?fit=max&auto=format&n=uys6iMwf9B_ojh8r&q=85&s=003d7870f36310d14ca9a71a952667d3)

Generate a cartoon using Fal.ai in Next.js
------------------------------------------

Convert an image to a cartoon using Fal.ai.

Vercel sync environment variables
---------------------------------

Learn how to automatically sync environment variables from your Vercel projects to Trigger.dev.

Vercel AI SDK
-------------

Learn how to use the Vercel AI SDK, which is a simple way to use AI models from different providers, including OpenAI, Anthropic, Amazon Bedrock, Groq, Perplexity etc.

Was this page helpful?

YesNo

[Previous](https://trigger.dev/docs/guides/examples/vercel-ai-sdk)
[dotenvxA dotenvx package for Trigger.dev.\
\
Next](https://trigger.dev/docs/guides/community/dotenvx)

⌘I

Assistant

Responses are generated using AI and may contain mistakes.
