vercel deploy
The vercel deploy command deploys Vercel projects, executable from the project's root directory or by specifying a path. You can omit 'deploy' in vercel deploy, as vercel is the only command that operates without a subcommand. This document will use 'vercel' to refer to vercel deploy.
vercelUsing the vercel command from the root of a Vercel
project directory.
Vercel automatically detects eligible static deployments and makes them ready without a build step. This optimization supports deployments containing only HTML (.html, .htm) or Markdown (.md) files, with up to 100 files and a total size of up to 25 MB.
Eligibility also depends on your project's build settings and deployment configuration. Other deployments automatically use the standard deployment flow.
Deploy one static file by passing its path to vercel or vercel deploy. The CLI uploads only that file, using static settings:
vercel index.html
vercel deploy README.mdA single-file deployment doesn't use the project that the directory is linked to. By default, the file deploys to a project named after the file. To choose the project, pass --project.
When you're logged in, single-file deployments accept any file extension. A single-file temporary deployment supports only .html files. To deploy other files without logging in, run vercel deploy --temporary on a directory, which works for any project. Use --dry to preview the deployment without uploading:
vercel index.html --dry
vercel index.html --temporarySingle-file deployments have these constraints:
--prebuilt,--archive, and--local-configrequire a directory deployment.- The CLI refuses files excluded by
.vercelignoreor the default ignore list. - Hidden files require confirmation because the deployment serves the file publicly. In scripts, pass
--yesto confirm explicitly.
The fast static deployment eligibility rules still determine whether the deployment can skip the build step.
vercel --cwd [path-to-project]Using the vercel command and supplying a path to the
root directory of the Vercel project.
vercel deploy --prebuiltUsing the vercel command to deploy a prebuilt Vercel
project, typically with vercel build. See
vercel build and
Build Output API for more details.
When deploying, stdout is the Deployment URL. With the --json option or in non-interactive mode, stdout is a JSON document instead.
vercel > deployment-url.txtUsing the vercel command to deploy and write
stdout to a text file. Unless you use --json or non-interactive mode,
stdout is always the Deployment URL.
In the following example, you create a bash script that you include in your CI/CD workflow. The goal is to have all preview deployments be aliased to a custom domain so that developers can bookmark the preview deployment URL. Note that you may need to define the scope when using vercel alias
# save stdout and stderr to files
vercel deploy >deployment-url.txt 2>error.txt
# check the exit code
code=$?
if [ $code -eq 0 ]; then
# Now you can use the deployment url from stdout for the next step of your workflow
deploymentUrl=`cat deployment-url.txt`
vercel alias $deploymentUrl my-custom-domain.com
else
# Handle the error
errorMessage=`cat error.txt`
echo "There was an error: $errorMessage"
fiThe script deploys your project and assigns the deployment URL saved in
stdout to the custom domain using
vercel alias.
If you need to check for errors when the command is executed such as in a CI/CD workflow,
use stderr. If the exit code is anything other than 0, an error has occurred. The
following example demonstrates a script that checks if the exit code is not equal to 0:
# save stdout and stderr to files
vercel deploy >deployment-url.txt 2>error.txt
# check the exit code
code=$?
if [ $code -eq 0 ]; then
# Now you can use the deployment url from stdout for the next step of your workflow
deploymentUrl=`cat deployment-url.txt`
echo $deploymentUrl
else
# Handle the error
errorMessage=`cat error.txt`
echo "There was an error: $errorMessage"
fiThese are options that only apply to the vercel command.
The --prebuilt option can be used to upload and deploy the results of a previous vc build execution located in the .vercel/output directory. See vercel build and Build Output API for more details.
If you run vercel redeploy on a prebuilt deployment, the redeploy reuses its prebuilt output and doesn't rebuild from source.
When using the --prebuilt flag, System Environment Variables will be missing at build time, so frameworks that rely on them at build time may not function correctly.
For Next.js projects, Skew Protection is supported with --prebuilt by configuring a custom deployment ID. See Custom Deployment ID for setup instructions. Prebuilt deployments cannot use dpl_ as a user-configured deployment ID prefix.
If you need System Environment Variables at build time, do not use the --prebuilt flag or use Git-based deployments.
vercel --prebuiltYou should also consider using the archive option to minimize the number of files uploaded and avoid hitting upload limits:
# Build the project locally
vercel build
# Deploy the pre-built project, archiving it as a .tgz file
vercel deploy --prebuilt --archive=tgzThis example uses the vercel build command to build your project locally. It then uses the --prebuilt and --archive=tgz options on the deploy command to compress the build output and then deploy it.
The --build-env option can be used to provide environment variables to the build step.
vercel --build-env KEY1=value1 --build-env KEY2=value2Using the vercel command with the
--build-env option.
The --yes option can be used to skip questions you are asked when setting up a new Vercel project.
The questions will be answered with the provided defaults, inferred from vercel.json and the folder name. The --yes option does not choose a team. If you belong to more than one team, also pass the --scope option.
vercel --yesUsing the vercel command with the
--yes option.
The --env option can be used to provide environment variables at runtime.
vercel --env KEY1=value1 --env KEY2=value2Using the vercel command with the
--env option.
By default, vercel deploys to the project that the current directory is linked to. To deploy to a specific project without linking the directory, pass the project's name or ID with the --project option:
vercel --project my-projectUsing the vercel command with the
--project option.
The --prod option can be used to create a deployment for a production domain specified in the Vercel project dashboard.
vercel --prodUsing the vercel command with the
--prod option.
Must be used with --prod. The --skip-domain option will disable the automatic promotion (aliasing) of the relevant domains to a new production deployment. You can use vercel promote to complete the domain-assignment process later.
vercel --prod --skip-domainUsing the vercel command with the
--skip-domain option.
The --regions option can be used to specify which regions the deployments Vercel functions should run in.
vercel --regions sfo1Using the vercel command with the
--regions option.
The --no-wait option does not wait for a deployment to finish before exiting from the deploy command.
vercel --no-waitThe --force option is used to force a new deployment without the build cache.
vercel --forceThe --with-cache option is used to retain the build cache when using --force.
vercel --force --with-cacheThe --turbo option uses a Turbo build machine for one deployment without changing the project's build machine settings:
vercel deploy --turboThe --archive option compresses the deployment code into one or more files before uploading it. This option should be used when deployments include thousands of files to avoid rate limits such as the files limit.
In some cases, --archive makes deployments slower. This happens because the caching of source files to optimize file uploads in future deployments is negated when source files are archived.
vercel deploy --archive=tgzThe --logs option also prints the build logs.
vercel deploy --logsUsing the vercel deploy command with the
--logs option, to view logs from the build process.
The --meta option is used to add metadata to the deployment.
vercel deploy --meta KEY1=value1The CLI reads Git metadata from the local checkout. If the checkout has no Git metadata or uses a detached HEAD, a deployment can lack the branch association needed for branch-specific Preview variables and domains. Check the linked Vercel project, team, and branch shown on the deployment first.
For a GitHub-linked project, supply the branch explicitly when deploying source files:
vercel deploy --meta githubDeployment=1 --meta githubCommitRef=feature-checkoutUse the keys for your project's Git provider:
| Provider | Deployment marker | Branch key |
|---|---|---|
| GitHub | githubDeployment=1 | githubCommitRef |
| GitLab | gitlabDeployment=1 | gitlabCommitRef |
| Bitbucket | bitbucketDeployment=1 | bitbucketCommitRef |
Use the branch name, such as feature-checkout, rather than a pull request merge ref. These values describe the deployment; they do not check out the branch or connect a Git repository. Other provider metadata keys are not interchangeable by changing their prefix.
Confirm that the environment variable is assigned to Preview and the same branch, and that the branch domain is configured on this project. A production deployment uses Production settings even if you attach branch metadata. A named custom environment requires its own --environment value, such as --environment=staging.
For a local or prebuilt deployment, fetch the branch's variables before building:
vercel pull --environment=preview --git-branch=feature-checkout
vercel build
vercel deploy --prebuilt --meta githubDeployment=1 --meta githubCommitRef=feature-checkoutAdding metadata at upload time cannot change values already embedded in build output. For a custom environment, use matching commands: vercel pull --environment=staging, vercel build --environment=staging, and vercel deploy --prebuilt --environment=staging. After deploying, verify the environment and assigned domains in the dashboard.
Use the --environment option to define the environment you want to deploy to. This could be production, preview, or a custom environment. For production, --prod does the same as --environment=production.
The following example deploys to a custom environment named staging:
vercel deploy --environment=stagingThe --temporary option creates a temporary deployment without logging in. It applies only when the CLI has no credentials. If you are logged in, the CLI prints a warning and creates a normal deployment. In non-interactive mode, the command fails instead, so remove the option when you are logged in.
vercel deploy --temporaryThe CLI builds the project locally first and deploys the prebuilt output, unless you pass --prebuilt with an existing .vercel/output directory. Temporary deployments always target production, so passing --environment with any other value returns an error.
After deploying, the CLI prints a claim URL and how long until the deployment expires. Claim it to keep it live, then run vercel login to keep deploying that project.
Until the temporary project expires, you can run vercel deploy --temporary again to redeploy it. Once it expires, you can't redeploy it as a temporary deployment. Create an account with vercel signup, then run vercel deploy to deploy it again.
By default, vercel deploy displays suggested next steps and commands after a deployment completes. This can help you discover relevant CLI commands for common post-deployment tasks. Use the --guidance option to display them when you have turned guidance messages off.
vercel deploy --guidanceUsing the vercel deploy command with the
--guidance option to receive command suggestions.
The following global options can be passed when using the vercel deploy command:
For more information on global options and their usage, refer to the options section.
Was this helpful?