Why Set Up a React Project?
React needs a build tool to manage dependencies, compile JSX, and optimize performance. The two most popular ways to set up a React project are:
- Create React App (CRA) β Official but slower and its now Sunset
- Vite β Faster, modern alternative
Setting Up React with Vite
Vite is a modern build tool that offers:
- Faster development server.
- Better performance with ES modules.
- Optimized production build.
Steps to Create a React App with Vite
1. Open Terminal & Run:
npm create vite@latest my-app --template react
or using Yarn:
yarn create vite@latest my-app --template react
or using pnpm:
pnpm create vite@latest my-app --template react
2. Navigate to the project folder:
cd my-app
3. Install dependencies:
npm install
4. Start the development server:
npm run dev
Vite For
| Feature | Vite π | CRA π’ |
|---|---|---|
| Startup Speed | β‘ Instant | π Slow |
| Build Speed | π₯ Fast | πΆββοΈ Moderate |
| Uses Webpack? | β No (ES Modules) | β Yes |
| Production Build | β Optimized | β οΈ Heavier |
| Plugins Support | β Excellent (Rollup-based) | β Good (Webpack-based) |
Top comments (0)