Deploying on Vercel
Initialize a Vite App
npm create vite@latest
# Or
yarn create vite
Follow the prompts to create your project. Navigate to the project directory:
cd your-vite-projectInstall Dependencies
Ensure all dependencies are installed:
npm install
# Or
yarn installBuild the Vite App
Before deploying, build the Vite app for production:
npm run build
# Or
yarn buildThis will generate a dist/ folder, which contains the production build.
Install Vercel CLI
If you haven’t installed the Vercel CLI, install it globally:
npm install -g vercel Deploy Using Vercel CLI
To deploy your Vite app:
Login to Vercel
Run
vercel loginto authenticate with your Vercel account.
vercel loginDeploy the Project
Run vercel in your project directory
vercelThis command will guide you through the deployment setup. You will be asked to:
Link or create a new project.
Select the project scope (organization or personal).
Confirm the default settings.
The default settings should work for most Vite apps, but make sure the build command is set to:
npm run buildAnd the output directory is:
distRe-deploy or Update: If you make updates to your project later, run:
vercel --prodThis will deploy your updated Vite app to the production environment.
(Optional) Configure a vercel.json File
vercel.json FileYou can also create a vercel.json file to define custom settings for your deployment. In the root of your project, add:
{
"builds": [
{
"src": "vite.config.js",
"use": "@vercel/static-build",
"config": {
"distDir": "dist"
}
}
],
"routes": [
{ "src": "/(.*)", "dest": "/" }
]
}
This ensures that the correct build and routing settings are applied automatically.
View the Live URL
Once deployment is successful, Vercel will provide a live URL where your Vite app is hosted. You can visit the link to see your app in action.
That's it! Your Vite app is now live on Vercel.
Last updated