Deploying to Vercel
Vercel is a cloud platform for static sites and Serverless Functions that fits perfectly with Rasengan.js. It enables developers to host websites and web services that deploy instantly, scale automatically, and require no supervision, all with minimal configuration.
In this guide, you will learn how to deploy a Rasengan.js app to Vercel.
Prerequisites
Before you start, You need to:
- Have a Rasengan.js app ready to deploy. If you don't have one yet, you can create a new project using the
create-rasengan
CLI. - Build you app locally, in order to be sure that there is no error that occurs during the build process. You can do this by running the following command:
npm run build
-
Prepare your app by defining a
serverless function
because Rasengan.js need to run on the server side. Rasengan.js provides a simple way to create serverless functions using theRasengan CLI
.- Configure your
rasengan.config.js
file to use thevercel
hosting strategy:
rasengan.config.jsimport { defineConfig } from "rasengan"; export default defineConfig({ server: { production: { hosting: "vercel", }, }, });
- Then create a new serverless function using the
rasengan
CLI:
terminalnpm run prepare
This command will generate a new serverless function in the
api
directory.- Finally, you can add new generated files and folders into your git repository:
terminalgit add . git commit -m "Add serverless function"
- Configure your
Deploying to Vercel
To deploy your Rasengan.js app to Vercel, you need to follow these steps:
- Install the Vercel CLI by running the following command:
npm install -g vercel
- Login to your Vercel account by running the following command:
vercel login
- Deploy your app by running the following command:
vercel
- Follow the instructions to deploy your app to Vercel. But, you have to change the following scripts used by vercel to deploy your app:
build command: npm run build
development command: npm run dev
- Once the deployment is complete, you will get a URL where your app is hosted.
That's it! Your Rasengan.js app is now deployed to Vercel.