React Project Setup (Vite & Next.js)
How to initialize a modern React project: creating a Vite SPA or a Next.js App Router full-stack application with TypeScript and Tailwind CSS.
React Project Setup (Vite & Next.js)
The React team recommends initializing new applications using a production framework like Next.js (for full-stack, SEO, and SSR) or Vite (for client-side Single Page Applications).
Option 1: Next.js App Router (Full-Stack & SSR)
For production web applications with server components, file-based routing, and SEO:
pnpm create next-app@latest my-app --typescript --tailwind --eslint --appNavigate and start development server:
cd my-app
pnpm devOption 2: Vite (Client-Side Single Page Application)
For client-only dashboards, widgets, or internal tools:
pnpm create vite my-app --template react-tsInstall dependencies and start dev server:
cd my-app
pnpm install
pnpm dev3. Recommended Project Structure
src/
├── app/ (or routes/) # Page routes and layouts
├── components/ # Reusable UI components
│ └── ui/ # Buttons, inputs, dialogs
├── hooks/ # Reusable custom React hooks
├── lib/ # Utility helpers and API clients
├── types/ # TypeScript type definitions
└── styles/ # Global CSS stylesheetRelated Topics
Introduction to React
Understanding React: component-driven UI architecture, declarative rendering, React 19 features, and the Virtual DOM.
React Components & Function Architecture
Building React components: functional components, return requirements, PascalCase naming, component purity, and folder organization.