A modern, responsive web application template built with React Router v7, Redux Toolkit, and Tailwind CSS. This template demonstrates best practices for state management, routing, and responsive design in a React application.
- React Router v7 - Latest routing solution with file-based routing
- Redux Toolkit - Simplified Redux for predictable state management
- Tailwind CSS v4 - Utility-first CSS framework with dark mode support
- TypeScript - Full type safety throughout the application
- Responsive Design - Mobile-first approach with responsive breakpoints
- Dark Mode - Automatic dark mode support based on system preferences
- Vite - Fast build tool and development server
- Docker - Containerization support for easy deployment
react-router-redux/
├── app/
│ ├── components/ # Reusable UI components
│ │ └── Counter.tsx # Example counter component
│ ├── hooks/ # Custom React hooks
│ │ └── useRedux.ts # Redux hooks with proper typing
│ ├── routes/ # Route components (file-based routing)
│ │ └── home.tsx # Home page route
│ ├── store/ # Redux store configuration
│ │ ├── index.ts # Store setup and types
│ │ └── slices/ # Redux slices
│ │ └── counterSlice.ts
│ ├── welcome/ # Welcome page assets
│ ├── app.css # Global styles with Tailwind
│ ├── root.tsx # Root app component with providers
│ └── routes.ts # Route configuration
├── public/ # Static assets
├── Dockerfile # Docker configuration
├── package.json # Dependencies and scripts
├── react-router.config.ts # React Router configuration
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite configuration
React Router v7 introduces file-based routing where route components are automatically discovered from the app/routes/
directory:
app/routes/home.tsx
→/
routeapp/routes/about.tsx
→/about
route (if created)app/routes/users/$userId.tsx
→/users/:userId
dynamic route
Each route file can export:
default
- The route componentmeta
- Page metadata (title, description)loader
- Server-side data loadingaction
- Form submission handling
The Redux store is configured using Redux Toolkit for simplified state management:
// app/store/index.ts
export const store = configureStore({
reducer: {
counter: counterReducer,
// Add more slices here
},
});
Slices contain all related logic for a feature:
// app/store/slices/counterSlice.ts
const counterSlice = createSlice({
name: "counter",
initialState: { value: 0 },
reducers: {
increment: (state) => {
state.value += 1;
},
decrement: (state) => {
state.value -= 1;
},
},
});
Components follow these patterns:
Functional Components with Hooks:
const Counter = () => {
const count = useSelector((state: RootState) => state.counter.value);
const dispatch = useDispatch();
// Component logic
};
Responsive Design with Tailwind:
- Mobile-first approach using
sm:
,md:
,lg:
prefixes - Dark mode support with
dark:
prefix - Utility classes for consistent spacing and typography
- Component dispatches an action
- Redux slice processes the action and updates state
- useSelector hook triggers re-render with new state
- Component reflects the updated state
User Interaction → Action Dispatch → Reducer → State Update → UI Re-render
The template uses a mobile-first responsive design:
- Base styles: Mobile (< 640px)
- sm: Small tablets (≥ 640px)
- md: Tablets (≥ 768px)
- lg: Desktop (≥ 1024px)
- xl: Large desktop (≥ 1280px)
Example responsive patterns:
<div className="flex flex-col sm:flex-row gap-4">
{/* Stacks vertically on mobile, horizontally on tablet+ */}
</div>
<h1 className="text-3xl sm:text-4xl lg:text-5xl">
{/* Progressive text sizing */}
</h1>
- Node.js 18+
- npm or yarn package manager
-
Clone the repository:
git clone <repository-url> cd react-router-redux
-
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Open your browser: Navigate to
http://localhost:5173
npm run dev
- Start development server with hot reloadnpm run build
- Build production-ready applicationnpm run start
- Start production servernpm run typecheck
- Run TypeScript type checking
Build and run the application in a container:
# Build the Docker image
docker build -t react-router-redux .
# Run the container
docker run -p 3000:3000 react-router-redux
-
Create a new file in
app/routes/
:// app/routes/about.tsx export default function About() { return <div>About Page</div>; }
-
The route is automatically available at
/about
-
Create a slice file:
// app/store/slices/userSlice.ts const userSlice = createSlice({ name: "user", initialState: { name: "", email: "" }, reducers: { setUser: (state, action) => { state.name = action.payload.name; state.email = action.payload.email; }, }, });
-
Add to store:
// app/store/index.ts export const store = configureStore({ reducer: { counter: counterReducer, user: userReducer, // Add here }, });
Customize the design system in app/app.css
:
@theme {
--color-primary: #3b82f6;
--font-sans: "Inter", ui-sans-serif, system-ui;
}
While not included in this template, recommended testing approaches:
- Unit Tests: Jest + React Testing Library
- Integration Tests: Test Redux actions and selectors
- E2E Tests: Playwright or Cypress for user flows
npm run build
# Deploy the `build/client` directory
npm run build
npm run start
docker build -t react-router-redux .
docker run -p 3000:3000 react-router-redux
The containerized application can be deployed to any platform that supports Docker, including:
- AWS ECS
- Google Cloud Run
- Azure Container Apps
- Digital Ocean App Platform
- Fly.io
- Railway
Create .env
file for environment-specific settings:
VITE_API_URL=https://api.example.com
VITE_APP_NAME=My App
Access in code:
const apiUrl = import.meta.env.VITE_API_URL;
The tsconfig.json
includes path mapping for clean imports:
{
"compilerOptions": {
"paths": {
"~/*": ["./app/*"]
}
}
}
This allows imports like:
import Counter from "~/components/Counter";
import { store } from "~/store";
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- React Router for the excellent routing solution
- Redux Toolkit for simplified state management
- Tailwind CSS for the utility-first CSS framework
- Vite for the fast build tool
Happy coding! 🎉