Reference

Framework environment variables

Vercel Environment variables that are automatically populated by the System, such as the URL of the Deployment or the name of the Git branch deployed.
Table of Contents

Frameworks typically use a prefix in order to expose environment variables to the browser.

The following prefixed environment variables will be available during the build step, based on the project's selected framework preset.

The environment that the app is deployed and running on. The value can be either production, preview, or development.

.env
NEXT_PUBLIC_VERCEL_ENV=production

The domain name of the generated deployment URL. Example: *.vercel.app. The value does not include the protocol schemehttps://.

.env
NEXT_PUBLIC_VERCEL_URL=my-site.vercel.app

The domain name of the generated Git branch URL. Example: *-git-*.vercel.app. The value does not include the protocol scheme https://.

.env
NEXT_PUBLIC_VERCEL_BRANCH_URL=my-site-git-improve-about-page.vercel.app

A production domain name of the project. We select the shortest production custom domain, or vercel.app domain if no custom domain is available. Note, that this is always set, even in preview deployments. This is useful to reliably generate links that point to production such as OG-image URLs. The value does not include the protocol scheme https://.

.env
NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL=my-site.com

The Protection Bypass for Automation value, if the secret has been generated in the project's Deployment Protection settings.

.env
NEXT_PUBLIC_VERCEL_AUTOMATION_BYPASS_SECRET=secret

The Git Provider the deployment is triggered from.

.env
NEXT_PUBLIC_VERCEL_GIT_PROVIDER=github

The origin repository the deployment is triggered from.

.env
NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG=my-site

The account that owns the repository the deployment is triggered from.

.env
NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER=acme

The ID of the repository the deployment is triggered from.

.env
NEXT_PUBLIC_VERCEL_GIT_REPO_ID=117716146

The git branch of the commit the deployment was triggered by.

.env
NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF=improve-about-page

The git SHA of the commit the deployment was triggered by.

.env
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA=fa1eade47b73733d6312d5abfad33ce9e4068081

The message attached to the commit the deployment was triggered by.

.env
NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE=Update about page

The username attached to the author of the commit that the project was deployed by.

.env
NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN=johndoe

The name attached to the author of the commit that the project was deployed by.

.env
NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME=John Doe

The pull request id the deployment was triggered by. If a deployment is created on a branch before a pull request is made, this value will be an empty string.

.env
NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID=23

Many frontend frameworks require prefixes on environment variable names to make them available to the client, such as NEXT_PUBLIC_ for Next.js or PUBLIC_ for SvelteKit. Vercel adds these prefixes automatically for your production and preview deployments, but not for your local development environment.

Framework environment variables are not prefixed when pulled into your local development environment with vercel env pull. For example, VERCEL_ENV will not be prefixed to NEXT_PUBLIC_VERCEL_ENV.

To use framework-prefixed environment variables locally:

  1. Define them in your project settings with the appropriate prefix
  2. Scope them to Development
  3. Pull them into your local environment with Vercel CLI using the vercel env pull command
Last updated on September 18, 2024