1. Configure Vite
In your React app, update the vite.config.js
file as follows:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
base: './',
build: {
outDir: 'dist',
},
});
public/_redirects
→ Add this file in public folder
this is for handling refreshing issue in the routes
/* /index.html 200
2. Deploy to Netlify
Step 1: Navigate to Netlify and Authorize with GitHub
- Go to the Netlify website.
- Log in or sign up for an account.
- Authorize Netlify to access your GitHub account.
Step 2: Add a New Site
- In the Netlify dashboard, click on Add New Site.
- Select Import an Existing Project.
Step 3: Connect to GitHub
- Select GitHub as your Git provider.
- Choose the repository that contains your Vite React project.
Step 4: Configure Site Settings
- Site Name: Enter a unique site name, e.g.,
https://your-site-name.netlify.app
.
- Base Directory: Provide the path of the folder containing your React site (if your React app is in the root directory, leave this blank).