Skip to content
Home / Migrations / Create React AppVite

Create React App Vite

easy

CRA is deprecated. Vite is the recommended replacement. Most CRA apps migrate in under 2 hours.

Estimated: 1-2h · 5 steps
Progress0%
Step 1: Install Vite
npm install -D vite @vitejs/plugin-react && npm uninstall react-scripts
Step 2: Create vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({ plugins: [react()] })
Step 3: Move index.html

Move public/index.html to root. Replace %PUBLIC_URL% with empty string. Add <script type="module" src="/src/index.tsx">.

Step 4: Replace env vars

REACT_APP_ → VITE_. process.env → import.meta.env.

find src -name '*.ts*' -exec sed -i 's/process.env.REACT_APP_/import.meta.env.VITE_/g' {} +
Step 5: Update scripts

dev: vite, build: vite build, preview: vite preview.

App runs with no errors