Installation
Install shadcn/ui Router
How to install shadcn/ui with React Router v7. Setup guide for the new framework features and built-in bundling.
How to install shadcn/ui with React Router
React Router v7 isn't just a router anymore—it's a full framework with bundling, server rendering, and more. Perfect with shadcn/ui for modern React apps.
React Router v7 setup
Create React Router app
npx create-react-router@latest my-app
cd my-app
Choose TypeScript when prompted for better component IntelliSense.
Initialize shadcn/ui
npx shadcn@latest init
The CLI detects React Router and configures everything correctly.
Add components
npx shadcn@latest add button card navigation-menu
Components are added to app/components/ui/
.
Use in your routes
// app/routes/home.tsx
import { Button } from "~/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"
import type { Route } from "./+types/home"
export function meta({}: Route.MetaArgs) {
return [
{ title: "React Router + shadcn/ui" },
{ name: "description", content: "Modern React with beautiful components" },
]
}
export default function Home() {
return (
<div className="container mx-auto p-8">
<Card>
<CardHeader>
<CardTitle>Welcome to React Router v7</CardTitle>
</CardHeader>
<CardContent>
<p>Full-stack React with shadcn/ui components</p>
<Button className="mt-4">Get Started</Button>
</CardContent>
</Card>
</div>
)
}
File structure
react-router.config.ts
components.json
Deployment
React Router v7 apps deploy anywhere:
Platform | Setup | Best For |
---|---|---|
Vercel | Automatic detection and setup | Zero config deployment |
Netlify | Built-in adapter support | Great build features |
Cloudflare | Workers and Pages | Edge performance |
AWS | Lambda or containerized | Enterprise scale |
Node.js | Any Node host | Traditional hosting |
Migration from v6
If upgrading from React Router v6:
- Update to v7:
npm install react-router@latest
- Move routes to
app/routes/
- Update imports from
react-router-dom
toreact-router
- Add shadcn/ui with the CLI
Next steps
With React Router v7 + shadcn/ui configured:
- Browse official components for forms, tables, and UI elements
- Add charts for data visualization
- Explore community components for extended functionality
- Add useful hooks to enhance your components
- Use pre-built blocks to quickly build common layouts
React Router v7's framework features combined with shadcn/ui's components give you everything needed for production React apps.