When you trigger a deploy, Vercel builds your project. For many frontend frameworks, Vercel automatically configures the build settings, but you can also customize them. You can also use Environment Variables to avoid hardcoding values.
To customize the build settings for your project, choose a project from the dashboard:
Then, select the Settings tab:
You can then edit the build settings from the Build & Development Settings, Root Directory, and Environment Variables sections.
Vercel tries to automatically detect the frontend framework you’re using for your project and configure the project settings for you. If you’d like to override the settings or specify a different framework, you can do so from the Build & Development Settings section.
Vercel detects the following frontend frameworks automatically and chooses the best default settings for you.
If no framework is detected, "Other" will be selected for you.
You can always choose a different framework preset or "Other" if you’d like.
If Vercel detects a framework, the Build Command will automatically be configured. Depending on a framework, the Build Command can refer to the project’s configuration file.
For example, if you choose Next.js, here’s what happens by default:
scripts, this command will be used to build the project.
- If not,
next buildwill be the Build Command.
If you’d like to override the Build Command, you can turn on the Override toggle and specify the command.
Skip Build Step
Some static projects do not require building. An example of this would be a website with only HTML/CSS/JS source files that can be served as-is (For example, you might just have a single
In such cases, you should:
- Specify "Other" as the framework preset, and
- Enable the Override option for the Build Command, and
- Leave the Build Command empty.
This will prevent the build from being attempted and serve your content as-is.
After building a project, most frameworks will output the result in a directory. Contents in this output directory will be the only things that will be statically served by Vercel.
If Vercel detects a framework, the output directory will automatically be configured.
In some cases, your project might not require building, and you might just want to serve the files in the root directory. If so, try the following:
- Choose "Other" as the framework preset. If you do so, by default, the output directory will be set as
publicif it exists, or
.(current directory) otherwise.
- Therefore, as long as your project doesn’t have the
publicdirectory, it will serve the files in the root directory.
- Alternatively, you can turn on the Override toggle and leave the field empty (in which case, the build step will be skipped).
During the Build Step, Vercel attempts to install dependencies by running
yarn install (or
npm install if
package-lock.json is present) in the path you've defined in the Root Directory section.
lockfileVersion2 or greater.
This will automatically install all dependencies defined in
devDependencies, which can be excluded like this).
If you’d like to override the Install Command, you can turn on the Override toggle and specify the command.
Custom Install Command for Your API
If you're using a frontend framework that also supports Serverless Functions for APIs, the Install Command defined in the Project Settings will be used.
In the case that you're using Serverless Functions that were defined in the natively supported
api directory, however, a different Install Command will be used depending on the language of the Serverless Function. For those, it cannot be customized.
This setting is relevant only if you’re using
vercel dev locally to develop your project. You should be using
vercel dev only if you need to use a Vercel platform feature like Serverless Functions. In other cases, you should use the development command your framework provides (such as
next dev for Next.js).
The Development Command setting allows you to customize the behavior of
vercel dev. If Vercel detects a framework, the development command will automatically be configured.
If you’d like to use a custom command for
vercel dev, you can turn on the Override toggle. Please note the following:
- If you specify a custom command, your command must pass the
$PORTvariable (which contains the port number) to your framework. For example, for Next.js, you should use:
next dev --port $PORT.
- If the development command is not specified,
vercel devwill fail. If you selected "Other" as the framework preset, the development command will be empty by default.
- You must create a deployment and have your local project be linked to the project on Vercel (using
vercel devwon’t work correctly.
In some projects, the top-level directory of the repository may not be the root directory of the app you’d like to build. For example, your repository might have a
frontend directory, which contains a stand-alone Next.js app.
In cases like this, you can specify the project root directory. If you do so, please note the following:
- If you specify a root directory, then your app won’t be able to access files outside of that directory. You also cannot use
..to move up a level.
- This setting also applies to Vercel CLI. Instead of running
vercel <directory-name>to deploy, specify
<directory-name>here so you can just run
You can configure Environment Variables for the Build Step directly from Project Settings. Check out the Environment Variables documentation to learn more.
By default, Vercel ignores certain files and folders for security and performance reasons, preventing them from being uploaded during the deployment process.
.hg .git .gitmodules .svn .cache .next .now .vercel .npmignore .dockerignore .gitignore .*.swp .DS_Store .wafpicke-* .lock-wscript .env.local .env.*.local .venv npm-debug.log config.gypi node_modules __pycache__ venv CVS
A build can last for a maximum of 45 minutes. If the build exceeds this time, the deployment will error.
Vercel intelligently caches files based on the Framework Preset selected in your Project Settings. The following files are cached in addition to
Each Deployment contains one or more separate Builds, and each type of Build has a dedicated cache. Together, they are the "Build Step".
The Build's cache key is derived from the combination of the following data:
At the beginning of each Build, the previous Build's cache is restored prior to the Install Command or Build Command executing. This means that your first Build for a given Project might be slower because dependencies must be installed, but subsequent Builds will be faster.
When a new Git branch is created, there will not be a cache for that specific branch. Instead, the last Production Deployment cache will be used and a new branch cache will be created.
At the end of each Build Step, successful Builds will update the cache and failed Builds will not modify the existing cache.
Deployments made using the "Redeploy" button on the Dashboard or using
vercel --force on Vercel CLI will also delete any previously successful Build's cache prior to starting the Build Step of the new Deployment.
The maximum size of a Build's cache is 1 GB and is retained for one month.
It is not possible to manually configure which files are cached at this time.
Every Build is provided with 8192 MiB of memory.
To install private npm modules, define
NPM_TOKEN as an Environment Variable in your Project.
NPM_RC as an Environment Variable with the contents of
Deploying Git submodules with a Git provider is supported as long as the submodule is publicly accessible via the HTTP protocol. Git submodules that are private or requested over SSH will fail during the Build step.
You can customize the Install Command to be
npm install --only=production or
yarn install --production in order to install only production dependencies and skip development dependencies.
If you need to ignore the cache for a deployment, you can do so by using the
-f flag for Vercel CLI. This prevents the cache from being used in the deployment and ensures a fresh install for all dependencies.
Some frameworks do not use
package.json to select a specific version to install during build time.
By including an Environment Variable, you can define your framework's version with one of the following:
Environment Variable Name
For example, to select Hugo v0.61.0 you would add an Environment Variable named
HUGO_VERSION with value
0.42.0does not exist but Hugo
The platform uses Amazon Linux 2 as the base image for the Build Step – along with several pre-installed packages.
yum(the default package manager for Amazon Linux 2) on the build image:
- automake: 1.13.4
- gifsicle: 1.91
To get started with Amazon Linux 2 locally, run the following command:
Once you're done, run
docker run --rm -it amazonlinux:2.0.20191217.0 sh
exitto stop executing it.
The build image includes access to repositories with stable versions of popular packages.
You can list all packages by adding the following to your Build Command:
You can search for a package by name with the following:
You can install a package by name with the following:
yum search my-package-here
If you need a new software package or a newer version of an existing software package that is not included in the default repositories, you can use Amazon Linux Extras.
yum install my-package-here -y
You can list extra packages with the following:
You can install extra packages with the following:
amazon-linux-extras install my-package-here
For more information on what to do next, we recommend the following articles: