Skip to content
React

Setting Up a React Project with Vite and Tailwind CSS

A practical guide on setting up a React project using Vite and Tailwind CSS, with steps for TypeScript integration and configuration.

Topic
React
Reading time
4 min
Length
916 words
Published
Aug 24, 2026
03:19 pm IST
In this article
  1. Initial Setup
  2. Creating the React Project
  3. Running the Project
  4. Integrating Tailwind CSS
  5. Configuring Tailwind CSS
  6. Setting Up the Favicon
  7. Final Touches
  8. What I'd Do on Monday
  9. Limitations and Considerations

Getting a React project off the ground doesn't have to be a hassle. With the right tools, you can streamline the process. Vite, in particular, is gaining traction among developers. Here, I’ll guide you through setting up a React project using Vite, along with TypeScript and Tailwind CSS for styling.

Initial Setup

The first step is to make sure Node.js is installed on your machine. If it’s missing, grab it from the official Node.js site. Node.js is non-negotiable because it comes with npm, the package manager we need to kick off our project. It allows us to execute JavaScript outside a browser, which is a cornerstone of modern web development.

Creating the React Project

Once Node.js is ready, open your terminal and head to the directory where you'd like to create your project. Run this command:

npm create vite@latest my_project -- --template react-ts

This line does a few things:

  • npm: Uses the Node.js package manager for running commands and handling packages.
  • create vite: Fires up the Vite project generator, simplifying the project creation process.
  • @latest: Ensures you're using the newest version of create-vite, sidestepping any issues with outdated features.
  • my_project: Names your project directory. Feel free to use any name you prefer for the folder.
  • --: This separator ensures arguments after it go to the create-vite script instead of npm.
  • --template react-ts: Sets up your project with React and TypeScript, offering a solid start with static type checking.

After running this, the terminal will ask you to pick a linter. You can go with either Oxlint or ESLint. I usually opt for ESLint due to its wide range of rules and solid community support.

Running the Project

Once setup is done, you’ll be prompted to install dependencies and fire up the project right away. Saying 'Yes' here is your best bet to ensure everything's functioning. Vite spins up the development server, and you should see something like:

VITE v8.2.1 ready in 692 ms
➜ Local: http://localhost:5174/

Open that URL in your browser to see your fresh React app in action. The message also hints at other nifty options, like exposing the server to your network with --host, which is handy for testing on multiple devices.

Integrating Tailwind CSS

Tailwind CSS is all about speedy styling. To bring it into your project, enter your project folder and run:

cd my_project
npm install -D tailwindcss @tailwindcss/vite

The -D flag installs these as development dependencies. They're needed only during dev, not in production. Tailwind isn't just a set of styles; it creates CSS at build time, stripping out unused styles to keep things fast.

Next, tweak your vite.config.ts file to bring Tailwind CSS into the fold:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
  plugins: [react(), tailwindcss()],
});

This setup tells Vite to process Tailwind's directives during builds. Restart the server by pressing Ctrl+C and running npm run dev again to see the changes take effect.

Configuring Tailwind CSS

Your src/index.css file needs some Tailwind love. Add this import:

@import "tailwindcss";

Nuke any other content in this file—it's unnecessary. This inclusion brings in Tailwind's base styles and utilities. Make sure src/main.tsx imports this CSS file:

import './index.css';

This line makes sure Tailwind’s styles are applied throughout your app. For a clean slate, swap your src/App.tsx content with:

function App() {
  return <>Hello world</>;
}
export default App;

It's minimal, but it demonstrates that your React component is rendering with Tailwind in play. Delete the src/App.css file and anything in the assets folder. This helps keep things tidy as you start fresh.

Setting Up the Favicon

Personalizing your project's favicon can aid in branding. Pick an icon, name it icon.png, and drop it in the public folder. Update your index.html to use this icon:

<link rel="icon" type="image/png" href="/icon.png" />

If the favicon doesn’t update, try clearing your browser cache. Browsers sometimes hold onto favicon images more than you'd like.

Final Touches

Your project's README.md deserves some attention. It represents your project, so it should clearly explain how to run and use the app. A well-laid-out README covers project description, installation steps, usage instructions, and contribution guidelines. Don’t forget to set up a License.md and kick off version control with Git:

git init
git add .
git commit -m "init"

Git is essential for tracking changes and collaborating. With these steps, your React project is ready for further development. Using Vite for speedy builds and Tailwind CSS for flexible styling gives you a fantastic base for modern web apps.

What I'd Do on Monday

Come Monday, I’d be diving into the newest TypeScript features to make sure my project is tapping into all the benefits TypeScript has to offer. That means checking out new syntax and settings that could boost code quality and developer experience. I'd also take a look at potential security measures to keep the app safe during development. Implementing security best practices early can fend off future issues.

Limitations and Considerations

This guide doesn’t dive into deployment strategies, testing frameworks, or advanced state management like Redux. These are crucial for a production-ready app and should be on your radar after you've got the basics down. Think about deployment options like Vercel or Netlify for smooth hosting. For testing, Jest and React Testing Library are solid picks. While Tailwind CSS is powerful, it might not be the best fit for projects with complex design needs—there, a more traditional CSS approach or a framework like Styled Components might be a better match.

Sources

Setting Up React Project

Every claim above was checked against this source before publishing. The analysis, the code and the opinions are mine.

Frequently asked

Why use Vite for setting up a React project?

Vite offers fast build times and hot module replacement, making it ideal for modern web development.

Is TypeScript necessary for a React project?

While not mandatory, TypeScript adds strong typing, which helps in catching errors early and improving code quality.

Can I use another CSS framework instead of Tailwind?

Yes, you can opt for any CSS framework that suits your project's needs, such as Bootstrap or Bulma.

What if my favicon doesn't update?

Clear your browser's cache as it might be displaying the old icon from the cache.

Deepak Kumar

Written by

Deepak Kumar

Sr Software Engineer at India Today Group | Aaj Tak · MERN Stack · Generative AI

I build production web applications and Generative AI systems — React and Next.js on the front, Node.js and RAG pipelines behind them. I write here about what those systems actually do once real traffic hits them.

Message me