# Serverless Deployment
Serverless deployment means that we don't need to take care of setting up or maintaining server infrastructure. Instead, we only take care of our code and the deployment is being automatically done for us.
Below you will find several serverless deployment services and explanation how to use them.
# Vercel (formerly known as Zeit)
This serverless provider allows you to deploy your code to a subdomain of their now.sh
domain system.
The subdomain is generated by the value of the name
property listed in the now.json
file (more about this below) and a random hash string generated by the Vercel deployment service.
- Login in Vercel using the company account. See how to do this here (opens new window)
- Go to your
/dashboard
and click the "Import project" button. - Click on the "Continue" button under "From Git Repository"
- Select the Git provider your repository is located at (Github, Gitlab or Bitbucket).
- Link your account in the selected Git provider with Vercel. This step is done only once.
- Select the repository that you want to deploy and click "Import"
- Type the project name (or use the project name as it is in the Git provider). Click "Continue".
- Select the root folder. It usually is the
./
directory, so leave the field empty and click "Continue". - In the next screen:
- select the used framework. This will ususally be set to "Other" because we use a custom template for most of our repositories.
- type the
build
command as seen in thepackage.json
file. For examplenpm run build
oryarn build
- type the output directory. For example
dist
orpublic
. - type the development command (optional). This is usually left blank.
- click the "Deploy" button
- Go in the repository and create a new file called
now.json
. This file should contain the following:{ "version": 2 }
- Wait for Vercel to do its job. In a couple of minutes you should see the project deployed in your Vercel dashboard and a comment should be added by Vercel under the commit in the Git provider repository page. You will probably receive an email notification for this (and all further deployments)
- If you deploy a React, Angular or Vue app (a single page app), you might experience issues with the router not resolving subpages. In this case use the following in the
now.json
file{ "version": 2, "routes": [ { "handle": "filesystem" }, { "src": "/.*", "dest": "/index.html" } ] }