Deploy Frontity using Vercel
In their own words : Vercel is a cloud platform for static sites and Serverless Functions that fits perfectly with your workflow. It enables developers to host Jamstack sites and web services that deploy instantly, scale automatically, and requires no supervision, all with no configuration.
We strongly recommend this service as it is serverless, cheap, includes CDN, and really easy to set up.
It also supports the cache technique stale-while-revalidate (which they call Serverless Pre-Rendering). This is a powerful way to improve your site speed.

Table of Contents

Signup and Login into Vercel

To be able to deploy with vercel you need to have a Vercel account. You can signup here.
Once you have an account you have to login to Vercel from the terminal.
1
> npx vercel login
Copied!

Deploy your site under a Vercel domain

Deploying to Vercel is really easy and all the required configuration for Frontity projects is automatically set for you via a vercel.json file.
So, to deploy your Frontity site under a Vercel domain you have to:
  1. 1.
    ​Signup and Login (if you haven't already).

Create a vercel.json file

Create this vercel.json file and save it in the root of your Frontity project.
1
{
2
"version": 2,
3
"builds": [
4
{
5
"src": "package.json",
6
"use": "@frontity/now"
7
}
8
]
9
}
Copied!
​@frontity/now is a Frontity builder created especifically for Vercel. It encapsulates all the actions that need to be triggered on Vercel servers when deploying a Frontity project

Run deployment

Deploy Frontity using the vercel command (from the root of your project):
1
> npx vercel
Copied!
You should get something like this
1
Vercel CLI 19.2.0
2
? Set up and deploy β€œ~/PROJECTS/2020/FRONTITY/DEMOS/my-frontity-project”? [Y/n] y
3
? Which scope do you want to deploy to? myVercelScope
4
? Link to existing project? [y/N] n
5
? What’s your project’s name? my-frontity-project
6
? In which directory is your code located? ./
7
πŸ”— Linked to vercel-username/head-tags (created .vercel)
8
πŸ” Inspect: https://vercel.com/vercel-username/my-frontity-project/lofg8n03c [2s]
9
βœ… Production: https://my-frontity-project.vercel.app [copied to clipboard] [1m]
Copied!
More about Vercel scopes ​
Vercel will assign you a domain (something like your-project-name.vercel.app) that that will allow you to check your site online.
From the above deployment example we got the following URL's:
  • Live URL: https://my-frontity-project.vercel.app β†’ Our temporary URL assigned automatically by Vercel, We can check (and share) our site online from this URL
  • Inspect: https://vercel.com/vercel-username/my-frontity-project/settings β†’ Here we can check the status of our site and check the logs among other things
  • Project Settings: https://vercel.com/vercel-username/my-frontity-project/settings β†’ Here we can change domain and build settings among other things

Deploy your site under a custom domain

To deploy your site in Vercel under a custom domain you have to:

Add your custom domain to your Vercel project settings

By visiting the project settings URL provided in our previous deployment (https://vercel.com/vercel-username/my-frontity-project/settings in our example above) we can set a custom domain.
Add it, and you will be provided with a set of nameservers that you can use in your domain provider's configuration to point your custom domain to the Vercel nameservers.
vercel nameservers

Add a subdomain for your WordPress source

A subdomain can be used to separate your WordPress and Frontity deployments. They can be created within the Vercel dashboard under the domains section.
To setup a subdomain for your WordPress source, simply select your desired domain from the list and add a new DNS Record with type A and the IP address of your WordPress server.

Add Vercel nameservers in your domain provider

You need to set Vercel nameservers as custom DNS of your custom domain from your domain provider site.
If you don't know how to do this, contact your domain provider (GoDaddy, CloudFlare, etc)

Deploy

Finally, deploy Frontity using this command (from the root of your project):
1
> npx vercel --prod
Copied!
You should get something like this
1
β¬’ my-frontity-project npx vercel --prod
2
​
3
πŸ” Inspect: https://vercel.com/vercel-username/my-frontity-project/9ue4zsq9n [2s]
4
βœ… Production: https://mycustomtomain.com [copied to clipboard] [4s]
Copied!
This will create a deployment and assign it to your real site URL.
More about Vercel deployments​

Vercel and HTTPS

Vercel now forces all apps to be served over HTTPS. You therefore need to ensure that your WordPress site has a SSL certificate and that you connect to your WordPress API endpoint using HTTPS rather than HTTP.
1
{
2
"name": "@frontity/wp-source",
3
"state": {
4
"source": {
5
"url": "https://your-wordpress-blog-url/",
6
}
7
}
8
},
9
...
Copied!
The effect of using a HTTP only connection on a Frontity project deployed on Vercel will result in navigation links not working and getting stuck in the data.isFetching state (although apparently working on the local dev machine). The reason is that Frontity won't be able to fetch the content from the WordPress backend over HTTP on a pure HTTPS site.
Still have questions? Ask the community! We are here to help 😊
Last modified 4mo ago