
Sign up to save your podcasts
Or


In this guide, we’ll walk step-by-step through creating a fully functional React app using React Router v7, styled with TailwindCSS, and powered by Vite. This is your go-to tutorial for learning client-side routing in React — from setup to nested routes and 404 pages.
📦 Technologies Used
* React 19 (via Vite)
* React Router v7.6.3
* TailwindCSS 4.1+
* Vite (for fast build + dev server)
🛠️ Project Setup with Vite & TailwindCSS
React Router Crash Course: Step-by-Step Guide
React Router is the standard routing library for React. In this crash course, we’ll build a simple multi-page app using React Router v6+ and Vite. Let’s get started!
1. Project Setup
First, create a new React project using Vite:
npm create vite@latest react-router-crash-course -- --template react
Install React Router:
npm install react-router-dom
2. Project Structure
Organize your files as follows:
src/
3. Setting Up the Router
In main.jsx, wrap your app with BrowserRouter:
import React from "react";
4. Defining Routes
In App.jsx, set up your routes:
import { Routes, Route } from "react-router-dom";
5. Creating Navigation
In components/Navigation.jsx, add navigation links:
import { NavLink } from "react-router-dom";
6. Building Pages
Create simple components for each page in the pages/ directory. Example for HomePage.jsx:
function HomePage() {
Repeat for AboutPage.jsx, ContactPage.jsx, etc.
7. Dynamic Routes
In ProductDetailPage.jsx, use the useParams hook to get the product ID:
import { useParams } from "react-router-dom";
8. Nested Routes (Dashboard Example)
In DashboardLayout.jsx, use the Outlet component:
import { Outlet, NavLink } from "react-router-dom";
9. Handling 404s
In NotFoundPage.jsx:
function NotFoundPage() {
10. Running the App
Start your development server:
npm run dev
Visit
http://localhost:5173
to see your app in action!
Conclusion
You now have a working React app with multiple pages, nested routes, dynamic routes, and a 404 page—all powered by React Router. Experiment by adding more pages or features!
By Norbert B.M.In this guide, we’ll walk step-by-step through creating a fully functional React app using React Router v7, styled with TailwindCSS, and powered by Vite. This is your go-to tutorial for learning client-side routing in React — from setup to nested routes and 404 pages.
📦 Technologies Used
* React 19 (via Vite)
* React Router v7.6.3
* TailwindCSS 4.1+
* Vite (for fast build + dev server)
🛠️ Project Setup with Vite & TailwindCSS
React Router Crash Course: Step-by-Step Guide
React Router is the standard routing library for React. In this crash course, we’ll build a simple multi-page app using React Router v6+ and Vite. Let’s get started!
1. Project Setup
First, create a new React project using Vite:
npm create vite@latest react-router-crash-course -- --template react
Install React Router:
npm install react-router-dom
2. Project Structure
Organize your files as follows:
src/
3. Setting Up the Router
In main.jsx, wrap your app with BrowserRouter:
import React from "react";
4. Defining Routes
In App.jsx, set up your routes:
import { Routes, Route } from "react-router-dom";
5. Creating Navigation
In components/Navigation.jsx, add navigation links:
import { NavLink } from "react-router-dom";
6. Building Pages
Create simple components for each page in the pages/ directory. Example for HomePage.jsx:
function HomePage() {
Repeat for AboutPage.jsx, ContactPage.jsx, etc.
7. Dynamic Routes
In ProductDetailPage.jsx, use the useParams hook to get the product ID:
import { useParams } from "react-router-dom";
8. Nested Routes (Dashboard Example)
In DashboardLayout.jsx, use the Outlet component:
import { Outlet, NavLink } from "react-router-dom";
9. Handling 404s
In NotFoundPage.jsx:
function NotFoundPage() {
10. Running the App
Start your development server:
npm run dev
Visit
http://localhost:5173
to see your app in action!
Conclusion
You now have a working React app with multiple pages, nested routes, dynamic routes, and a 404 page—all powered by React Router. Experiment by adding more pages or features!