A modern, feature-rich template for building scalable React applications with the latest tools and best practices.
- 🚀 React 19 - Experience the future with the new React Compiler
- ⚡ Vite - Lightning-fast development with instant HMR
- 🎯 TypeScript - Type-safe development with latest features
- 🎨 TailwindCSS - Utility-first CSS with modern preset
- 🔄 TanStack Router - Type-safe routing with code splitting
- 📡 TanStack Query - Powerful data synchronization
- ✅ Vitest - Next-generation testing framework
- 📦 PNPM - Fast, disk space efficient package manager
- 🔍 ESLint + Prettier - Modern linting and code formatting
This template is designed to stay cutting-edge, which means it:
May not suit all workflows due to frequent updates with the latest tools and features.
Focuses on Client-Side Rendering (CSR) for SPAs. For SSR/SSG, consider using frameworks like:
Next.js
Remix (React Router 7)
TanStack Start (beta).
Includes experimental features that are tested but could still pose compatibility risks.
Latest lts for node js, and pnpm installed.
Two options here either use github's Use this template
button or do it by cloning the code, there is a script to help clean up git and setup it up.
# Clone the repository
git clone https://github.com/FerMPY/react-ts-template.git my-app
# Navigate to project directory
cd my-app
# Install dependencies
pnpm install
# CLean up git
pnpm node --experimental-strip-types ./scripts/setup.ts
# Start development server
pnpm dev
Command | Description |
---|---|
`pnpm dev` | Start development server |
`pnpm build` | Build for production |
`pnpm preview` | Preview production build |
`pnpm test` | Run tests |
`pnpm format` | Run Prettier over the code |
`pnpm lint` | Lint code |
`pnpm type-check` | Check types |
.
├── eslint.config.js
├── index.html
├── LICENCE
├── lint-staged.config.js
├── package.json
├── pnpm-lock.yaml
├── postcss.config.js
├── public
│ ├── React-icon.svg
│ ├── tailwind.png
│ ├── tanstack.webp
│ ├── typescript.svg
│ └── vite.svg
├── README.md
├── scripts
│ └── setup.ts
├── src
│ ├── components
│ ├── main.tsx
│ ├── queries
│ ├── routes
│ ├── routeTree.gen.ts
│ ├── styles
│ └── vite-env.d.ts
├── tailwind.config.ts
├── tests
│ ├── setup.tsx
│ └── utils
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
- ⚡ Route-based code splitting
- 🔄 Optimistic updates with TanStack Query
- 📦 Tree-shaking for smaller bundles
- 🎯 Type-only imports
- 🚀 React Compiler optimizations
This template comes with a little helper render-with-router
to help with writing tests with Tanstack Router, this comes with 2 options withUser that will add a user so you can run the tests and a with withQueryClient that adds Tanstack query to your tests, also globals are turned for Vitest.
// Example test using Vitest with render-with-router
import { renderWithRouter } from ".";
import { useRouter } from "@tanstack/react-router";
const TestComponent = () => {
const _router = useRouter({ warn: true });
return <div>TestComponent</div>;
};
describe('Button', () => {
it('renders correctly', () => {
{ user } = renderWithRouter(TestComponent, { withUser: true, withQueryClient: true });
user.click('button');
});
});
While this template provides a solid foundation, you might find these additional tools and libraries useful as your application grows:
Zustand: A minimal, unopinionated state management library cwith a simple API and hooks. Jotai: A primitive and flexible state management library for React with atomic state.
Fluid-Tailwind: A utility-focused library that extends TailwindCSS for a more fluid design approach. shadcn/ui: A modern library that combines design tokens and utility classes for rapid UI development.
Prisma: A powerful ORM for working with databases, enabling type-safe queries and schema migrations. Drizzle: A lightweight ORM alternative that offers a simpler API for SQL databases.
Radix UI: A library of low-level, unstyled UI components for accessibility and customization. Headless UI: Tailored for React and Vue, it provides accessible, unstyled components that work seamlessly with TailwindCSS. React Aria: A suite of React hooks that helps you build accessible and robust user interfaces.
- Fork the repository
- Create your feature branch (`git checkout -b feature/amazing-feature`)
- Commit your changes (`git commit -m 'Add amazing feature'`)
- Push to the branch (`git push origin feature/amazing-feature`)
- Open a Pull Request
- React 19 just released there could be dependency issues
- Some features might be experimental, they are tested before benign added to the template but still be careful.
Made with ❤️ by Fernando Mendoza