Part 2: Setting Up Your Development Environment with Vite

Part 2 Technology Updated September 12, 2026

Part 2: Setting Up Your Development Environment with Vite

To build production-grade React applications, having a fast, modern build tool is essential. While Create React App (CRA) was historically popular, it has been deprecated in favor of modern bundlers like Vite.


1. Why Vite over Create React App?

Vite (French for "fast", pronounced /vit/) created by Evan You revolutionizes the frontend developer experience: - Lightning Fast Cold Server Start: Uses native ES modules (ESM) in the browser during development; code is served on-demand without pre-bundling. - Instant Hot Module Replacement (HMR): Changes reflect in milliseconds regardless of the application size. - Extremely Fast Production Builds: Leverages Rollup under the hood with intelligent code-splitting and asset optimization. - Modern Defaults: Built-in support for JSX, TypeScript, CSS Modules, and PostCSS out of the box.


2. Prerequisites

Ensure you have Node.js (version 18.0 or higher recommended) installed:

node -v
npm -v

3. Creating a New React Project

Run the following command in your terminal:

npm create vite@latest devify-react-app -- --template react

Navigate into your project folder and install dependencies:

cd devify-react-app
npm install

Start the local development server:

npm run dev

You will see output indicating your app is running locally, typically at http://localhost:5173/.


4. Understanding the Project Structure

A clean Vite React project contains the following hierarchy:

devify-react-app/
├── index.html              # The single entry HTML page
├── package.json            # Project metadata & dependencies
├── vite.config.js          # Vite configuration
├── public/                 # Static assets (favicons, robots.txt)
└── src/
    ├── assets/             # Images and local static assets
    ├── App.css             # Main component styles
    ├── App.jsx             # Root React component
    ├── index.css           # Global CSS styles
    └── main.jsx            # Application entry point (DOM root mount)

Key Files Breakdown:

1. index.html

Unlike older webpack setups where HTML was generated dynamically, Vite treats index.html as the source entry point:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Devify React App</title>
  </head>
  <body>
    <!-- React mounts the entire component tree into this root div -->
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>

2. src/main.jsx

The bridge between the browser DOM and React:

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.jsx';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

Note on React.StrictMode: A development-only tool that highlights potential bugs by intentionally double-invoking lifecycle methods and effects to identify side-effect issues.


Key Takeaways

  • Vite provides instantaneous startup and HMR via native ES modules.
  • index.html hosts <div id="root"></div> where ReactDOM.createRoot() mounts the application.
  • React.StrictMode ensures best practices during development.

In Part 3, we will dive into JSX: its syntax rules, expressions, and compilation mechanics!