Skip to content

PixlGalaxy/Vite_React_Tailwind_Setup_Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Complete Guide to Creating a Web Application with Vite, React, and Tailwind CSS

Follow these steps to quickly set up a modern and efficient development environment.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Creating the Project with Vite
  4. Installing React Router
  5. Setting Up Tailwind CSS v4
  6. Installing Icon Libraries
  7. Project Structure
  8. Creating Components and Pages
  9. Setting Up Routes with React Router
  10. Starting the Development Server
  11. Conclusion

Introduction

In this guide, you will learn how to set up a modern web application using Vite 8, React 19, Tailwind CSS v4, React Router v7, Lucide React, and React Icons.
Vite offers a fast and efficient development environment, React makes it easy to build dynamic user interfaces,
Tailwind CSS provides a flexible and efficient way to design styles, and both icon libraries give you thousands of ready-to-use icons.

Prerequisites

Before getting started, make sure you have the following installed:

You can verify the installation by running the following commands in your terminal:

node -v
npm -v

Creating the Project with Vite

Vite simplifies the configuration of React projects. Below are two options: one for JavaScript projects and another for TypeScript projects.

  1. Run the following command to create a new project:

    npm create vite@latest project-name
  2. During the setup, you will be prompted to select a framework. Choose React.

  3. Next, you will be asked to select a variant. Choose JavaScript or TypeScript, depending on your preference.

  4. Navigate to your project folder:

    cd project-name
  5. Install the dependencies:

    npm install

Installing React Router

To enable navigation between pages, install React Router v7:

npm install react-router-dom

This will allow you to define and manage routes within your application.

Setting Up Tailwind CSS v4

Tailwind CSS v4 uses a PostCSS plugin for integration — no tailwind.config.js required.

  1. Install Tailwind CSS and its PostCSS dependencies:

    npm install -D tailwindcss @tailwindcss/postcss postcss autoprefixer
  2. Create a postcss.config.js file at the root of your project:

    export default {
      plugins: {
        '@tailwindcss/postcss': {},
      },
    }
  3. Replace all content in src/index.css with a single import:

    @import "tailwindcss";

That's it — no config file needed. Tailwind v4 auto-detects your template files automatically.

Installing Icon Libraries

Lucide React ^1.9.0

Lucide React provides a clean, consistent icon set.

npm install lucide-react
import { Home, Menu, ArrowRight } from 'lucide-react'

<Home size={24} />
<Menu className="w-6 h-6 text-blue-500" />
<ArrowRight size={18} />

React Icons ^5.6.0

React Icons includes icons from Font Awesome, Material Design, Heroicons, and many more.

npm install react-icons
import { FaGithub, FaReact } from 'react-icons/fa'
import { MdHome, MdInfo } from 'react-icons/md'

<FaGithub size={24} />
<MdHome className="text-blue-500" />

Project Structure

project-name/
├── src/
│   ├── components/
│   │   └── Navbar.tsx (or Navbar.jsx)
│   ├── pages/
│   │   ├── Home.tsx (or Home.jsx)
│   │   └── About.tsx (or About.jsx)
│   ├── App.tsx (or App.jsx)
│   ├── main.tsx (or main.jsx)
│   └── index.css
├── index.html
├── package.json
├── postcss.config.js
└── vite.config.ts (or vite.config.js)

Creating Components and Pages

Example Home.tsx (Page):

import { Link } from "react-router-dom";
import { ArrowRight, Info } from "lucide-react";

const Home = () => {
  return (
    <>
      <title>Welcome to my Page</title>
      <meta name="description" content="A shift to something with more potential." />

      <div className="min-h-screen flex flex-col items-center justify-center bg-gray-100 text-center">
        <h1 className="text-5xl font-bold text-blue-600">Welcome to My Page</h1>
        <p className="mt-4 text-lg text-gray-700">
          Still Working Here.
        </p>
        <div className="mt-6 flex space-x-4">
          <Link
            to="/about"
            className="flex items-center gap-2 px-6 py-3 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600 transition"
          >
            Learn More <ArrowRight size={18} />
          </Link>
          <Link
            to="/contact"
            className="flex items-center gap-2 px-6 py-3 bg-gray-500 text-white rounded-lg shadow-md hover:bg-gray-600 transition"
          >
            <Info size={18} /> Info
          </Link>
        </div>
      </div>
    </>
  );
};

export default Home;

Example Navbar.tsx (Component):

import { Link } from "react-router-dom";
import { Home, Info, BookOpen } from "lucide-react";

const Navbar = () => (
  <nav className="bg-white shadow-md p-4">
    <ul className="flex space-x-6 items-center">
      <li>
        <Link to="/" className="flex items-center gap-1 hover:text-blue-600 transition">
          <Home size={18} /> Home
        </Link>
      </li>
      <li>
        <Link to="/about" className="flex items-center gap-1 hover:text-blue-600 transition">
          <Info size={18} /> About
        </Link>
      </li>
      <li>
        <Link to="/docs" className="flex items-center gap-1 hover:text-blue-600 transition">
          <BookOpen size={18} /> Docs
        </Link>
      </li>
    </ul>
  </nav>
);

export default Navbar;

Setting Up Routes with React Router

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Navbar from "./components/Navbar";
import Home from "./pages/Home";

const App = () => (
  <Router>
    <Navbar />
    <Routes>
      <Route path="/" element={<Home />} />
    </Routes>
  </Router>
);

export default App;

Starting the Development Server

npm run dev

Access http://localhost:5173.

Conclusion

Now you have a fully configured application with Vite 8, React 19, Tailwind CSS v4, React Router v7, Lucide React, and React Icons, featuring functional routing, modern icons, and a modular structure ready to scale.
This guide was designed to streamline web development. Created by PixlGalaxy.

About

Complete Guide to Creating a Web Application with Vite, React, and Tailwind CSS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors