How to initialize React project

React
Vite
Published on: Jan 2, 2025
  1. install Node.js

  2. Terminal window
    npm create vite@latest react-app -- --template react-ts

    Create a new React project using Vite.

  3. package.json
    {
    "name": "react-app",
    "private": true,
    "version": "0.0.0",
    "type": "module",
    "scripts": {
    "dev": "vite",
    "build": "tsc -b && vite build",
    "lint": "eslint .",
    "preview": "vite preview"
    },
    "dependencies": {
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    },
    "devDependencies": {
    "@eslint/js": "^9.17.0",
    "@types/react": "^18.3.18",
    "@types/react-dom": "^18.3.5",
    "@types/react": "^19.0.2",
    "@types/react-dom": "^19.0.2",
    "@vitejs/plugin-react": "^4.3.4",
    "eslint": "^9.17.0",
    "eslint-plugin-react-hooks": "^5.0.0",
    "eslint-plugin-react-refresh": "^0.4.16",
    "globals": "^15.14.0",
    "typescript": "~5.6.2",
    "typescript-eslint": "^8.18.2",
    "vite": "^6.0.5"
    }
    }

    Increase the version of React and React DOM to the latest versions.

  4. Terminal window
    npm install

    Install the dependencies.

  5. Terminal window
    npm install -D tailwindcss postcss autoprefixer

    Install Tailwind CSS dependencies.

  6. Terminal window
    npx tailwindcss init -p

    Generate the Tailwind CSS configuration files.

  7. tailwind.config.js
    /** @type {import('tailwindcss').Config} */
    export default {
    content: [],
    content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
    ],
    theme: {
    extend: {},
    },
    plugins: [],
    }

    Set up the Tailwind CSS configuration.

  8. index.css
    @tailwind base;
    @tailwind components;
    @tailwind utilities;

    Add the Tailwind directives.

  9. App.tsx
    export default function App() {
    return (
    <h1 className="text-3xl font-bold underline">
    Hello world!
    </h1>
    )
    }

    Use Tailwind CSS classes in the React component.