Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React with Vite

Professional React Development with Build Tools

Welcome to the React with Vite section! This module bridges you from CDN-based React (opening HTML files in a browser) to professional React development with Vite — the way real projects are built.


Module Overview

Real React projects do not use CDN script tags. They use build tools like Vite that provide instant hot reload, proper file organization with imports/exports, third-party package management, and optimized production builds. In this module, you'll set up your first Vite project, organize code across multiple files, install npm packages, and build a complete multi-page application with routing.


Key Learnings

Topic Description
Vite Project Setup Creating, running, and building a React project with Vite
Components & Imports Splitting code into files, default/named exports, CSS per component
npm Packages Installing libraries, package.json, environment variables, config
Multi-Page Apps react-router-dom, navigation, dynamic routes, API fetching
MUI Component Library Material UI components, theming, sx prop, zero-CSS styling

Repository Structure

react-vite/
├── react-vite-1/    ⭐ Project Setup & Structure
│   └── README.md
│
├── react-vite-2/    ⭐⭐ Components, Imports & Styling
│   └── README.md
│
├── react-vite-3/    ⭐⭐⭐ npm Packages & Configuration
│   └── README.md
│
├── react-vite-4/    ⭐⭐⭐⭐ Vite React Mini Project
│   └── README.md
│
├── react-vite-5/    ⭐⭐⭐⭐⭐ MUI Material Design (Bonus)
│   └── README.md
│
└── README.md        📖 This file

Getting Started

Prerequisites

  • Completed the React Basics and React Advanced sections (or equivalent knowledge)
  • Node.js version 18 or higher installed (download here)
  • A modern web browser (Chrome, Firefox, Edge)
  • A code editor (VS Code recommended)
  • A terminal (Command Prompt, PowerShell, or VS Code integrated terminal)

How to Use This Repository

  1. Start with React Vite 1 — open the react-vite-1 folder
  2. Read README.md for detailed theory and code examples
  3. Follow the Activity Instructions — create your own Vite project and code along
  4. Progress sequentially — each module builds on the previous one
  5. Finish with React Vite 4 — a mini project combining everything
  6. Try the bonus — React Vite 5 rebuilds Part 4 with MUI (optional)

Running the Code (Step by Step)

Each folder (react-vite-1 through react-vite-5) contains a complete, working Vite project. You can run any of them directly:

  1. Open a terminal and navigate into a project folder: cd react-vite-1
  2. Install dependencies: npm install
  3. Start the dev server: npm run dev
  4. Open the URL shown in the terminal (usually http://localhost:5173)
  5. Edit files in src/ — the browser updates automatically via Hot Module Replacement
  6. When ready, build for production: npm run build
  7. Preview the production build: npm run preview

You can also create your own Vite project from scratch to practice: npm create vite@latest my-react-app -- --template react

Node.js is required for all modules in this section. Make sure node -v returns version 18 or higher before starting.


Module-by-Module Guide

React Vite 1: Project Setup & Structure ⭐

Difficulty: Intermediate

Set up your first professional React project:

  • Installing Node.js and using npm
  • Creating a Vite + React project from scratch
  • Understanding the project file structure
  • Hot Module Replacement (HMR) and the dev server
  • Building for production

Go to React Vite 1


React Vite 2: Components, Imports & Styling ⭐⭐

Difficulty: Intermediate

Organize your project with proper file structure:

  • One component per .jsx file
  • Default exports vs named exports
  • The src/components/ folder convention
  • CSS per component with import './Component.css'
  • Importing images and static assets

Go to React Vite 2


React Vite 3: npm Packages & Configuration ⭐⭐⭐

Difficulty: Intermediate+

Install packages and configure your project:

  • Installing third-party libraries (react-icons, clsx)
  • Understanding package.json and node_modules/
  • Environment variables with VITE_ prefix
  • Customizing vite.config.js (port, aliases)

Go to React Vite 3


React Vite 4: Vite React Mini Project ⭐⭐⭐⭐

Difficulty: Advanced

Build a complete multi-page application:

  • Professional folder structure (pages, components, styles)
  • Client-side routing with react-router-dom
  • Dynamic routes and URL parameters
  • API data fetching with loading and error states
  • Production build and deployment considerations

Go to React Vite 4


React Vite 5: MUI Material Design (Bonus) ⭐⭐⭐⭐⭐

Difficulty: Advanced

Rebuild Part 4 with a professional component library:

  • Why teams use MUI instead of custom CSS
  • Installing and configuring MUI with Emotion
  • ThemeProvider, createTheme, and CssBaseline
  • The sx prop for inline, theme-aware styling
  • MUI components: Typography, Card, Grid, AppBar, Alert, CircularProgress
  • MUI + React Router integration
  • Material Design icons

Go to React Vite 5


Tech Stack

Component Technology
Build Tool Vite 5
Frontend React 18
Package Manager npm
Routing (Vite 4, 5) react-router-dom
Icons (Vite 3) react-icons
UI Library (Vite 5) MUI (Material UI) 5
API (Vite 4, 5) JSONPlaceholder

Tips for Success

  1. Complete the advance section first — this module assumes you know components, state, effects, and fetching
  2. Type the code yourself — do not copy-paste. Typing builds muscle memory for imports, exports, and JSX
  3. Keep the terminal visible — Vite shows errors and warnings in real time
  4. One step at a time — get each activity step working before moving to the next
  5. Use git — commit after each module so you can go back if something breaks

Troubleshooting

Problem Solution
node -v not recognized Install Node.js from nodejs.org
npm create vite fails Update npm: npm install -g npm@latest
Dev server won't start Run npm install first to create node_modules/
Module not found error Check that import paths match file locations exactly
.jsx file not working Ensure the file extension is .jsx, not .js, for files with JSX
Env variables undefined Restart dev server; variable names must start with VITE_
Routes show blank page Verify BrowserRouter wraps the app in main.jsx
Build works but routes 404 on refresh Use npm run preview for testing; deploy to an SPA-aware host

Completion Checklist

  • React Vite 1: Project Setup & Structure
  • React Vite 2: Components, Imports & Styling
  • React Vite 3: npm Packages & Configuration
  • React Vite 4: Vite React Mini Project
  • React Vite 5: MUI Material Design (Bonus)

Additional Resources


Happy Coding!

You've gone from CDN script tags to professional React development. Every React job uses tools like these — you're building real-world skills!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages