Hosting
Learn how to host your website on a server and make it accessible to the public.
Choose a Hosting Provider
You can host your apps on a variety of hosting providers that supports Next.js.
Here are some popular hosting providers:
I recommend using Vercel, it's the company behind Next.js and offers a seamless deployment experience. I will be using Vercel in this guide.
Deploy to Vercel
Since we're using turborepo and have multiple apps (marketing and dashboard), we need to deploy each app separately.
We're going to deploy the marketing site under your-domain.com
and the dashboard under the app
subdomain, app.your-domain.com
.
This gives a clean separation between the marketing site and the dashboard, and gives a professional look to your website rather than having everything under the same domain.
Make sure to have the keys and secrets ready that you got from the previous steps.
Deploy the Marketing Site
Login to Vercel
Go to the Vercel dashboard and login with your credentials.
Import the repository
On the Overview
tab, click on the Add New...
dropdown and select Project
.
Select your repository and click Import
.
Configure the Project
Enter the project name suffixed with -marketing
, for example, your-project-name-marketing
.
Framework preset should be Next.js.
Override the build command with the following:
The root directory should be apps/marketing
.
Make sure the include source files outside of the Root Directory in the Build Step
is checked.
Node.js version should be 20.x
.
Environment Variables
Add the following environment variables:
Deploy
Click on the Deploy
button to deploy the marketing site.
Setup Custom Domain
Once the deployment is complete, go to the Settings
tab and click on Domains
.
In the input field, enter your domain name your-domain.com
and click Add
.
Follow the instructions to add the necessary DNS records to your domain registrar.
Be patient, it could take a few minutes for the DNS records to propagate.
Done
Once the DNS records have propagated, your marketing site will be live at https://your-domain.com
.
You will also be able to check the analytics of the website on the tinybird URL we bookmarked earlier.
Deploy the Dashboard Site
Login to Vercel
Go to the Vercel dashboard and login with your credentials.
Import your repository
On the Overview
tab, click on the Add New...
dropdown and select Project
.
Select your repository and click Import
.
Configure the Project
Enter the project name suffixed with -dashboard
, for example, your-project-name-dashboard
.
Framework preset should be Next.js.
Override the build command with the following:
The root directory should be apps/dashboard
.
Make sure the include source files outside of the Root Directory in the Build Step
is checked.
Node.js version should be 20.x
.
Environment Variables
Add the following environment variables:
Deploy
Click on the Deploy
button to deploy the dashboard site.
Setup Custom Domain
Once the deployment is complete, go to the Settings
tab and click on Domains
.
In the input field, enter your domain name app.your-domain.com
and click Add
.
Follow the instructions to add the necessary DNS records to your domain registrar.
Be patient, it could take a few minutes for the DNS records to propagate.
Done
Once the DNS records have propagated, your dashboard site will be live at https://app.your-domain.com
.
You will also be able to check the analytics of the website on the tinybird URL we bookmarked earlier.
Activate Speed Insights
Vercel Speed Insights is a tool that helps you monitor the performance of your website and provides suggestions to improve it.
I have already configured Vercel Speed Insights for you. If you wish to activate it you can do so in the Vercel dashboard.
Enable Speed Insights in Vercel
To access the Speed Insights tab for your project on Vercel's dashboard, first navigate to your Project, then click on the Speed Insights tab. Alternatively, you can directly visit the tab by clicking here. Next, choose "Enable" from the dialog to proceed.
You can activate Speed Insights for both the marketing and dashboard sites if you wish. However, doing so for the marketing site is most important.
Done
Congratulations, you have successfully deployed your marketing and dashboard site to Vercel. You're all set to jump right into your business now!
When modifications are made to the database schema and these changes are merged into the main branch, GitHub Actions will automatically execute the migrations and synchronize the production database schema.
Everytime you push to the main
branch, Vercel will automatically deploy the changes to the production environment.
Last updated on