Vercel is a serverless cloud-based hosting solution to host front-end and serverless applications. Express is a Node.JS framework and deploying serverless express application aids cost-cutting to nearly zero. Although the traditional way of deploying to the server is expensive and there is a limit on API calls plus you may need backend developers when the product is Scaled to a higher level. Therefore, we must learn how to deploy the serverless express application to Vercel.
Features of Vercel:
Prerequisites: Node.js must be installed. If you haven’t installed it yet, please refer to this article .
Steps to set up Vercel Account:
Go to the Vercel Website and Register with your Email or through your GitHub account.
Steps to build simple node.js express application:
npm init -y
npm install express
app.get(
'/api'
,(req,res)=>{
res.send(`<h5 style=
"color:green"
>
Hey Geek! you just deployed serverless express api</h5>`)
app.listen(8080,()=>{
module.exports=app
vercel login
vercel
The command will show the latest Vercel version and ask the following questions:
Further, if you want to deploy it to the production run the command:
vercel --prod
After the above deployment process is done, visit the Vercel website and your project will be deployed there.
example: https://geeksapi-panwarayush.vercel.app/api