Next.js
Install shadcn/ui in Next.js with the official CLI. App Router, then add a component from the shadcn.io registry. TypeScript and Tailwind CSS.
init -t next scaffolds the app. init alone configures an app you already created. Then add a file from the shadcn.io registry — official CLI, our URL.
Use the CLI
Create the project
Follow the prompts: base, preset, monorepo.
npx shadcn@latest init -t nextMonorepo:
npx shadcn@latest init -t next --monorepoAdd a component
Official registry:
npx shadcn@latest add cardshadcn.io registry — same CLI, our URL:
npx shadcn@latest add https://www.shadcn.io/r/card.jsonMonorepo: run from apps/web, or -c apps/web from the repo root.
Import it
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
export default function Home() {
return (
<Card className="max-w-sm">
<CardHeader>
<CardTitle>Project Overview</CardTitle>
<CardDescription>
Track progress and recent activity for your Next.js app.
</CardDescription>
</CardHeader>
<CardContent>
Your design system is ready. Start building your next component.
</CardContent>
</Card>
)
}Monorepo: edit apps/web/app/page.tsx and import from @workspace/ui/components/card.
Existing project
Create the app if you need one
Skip this if the repo already exists.
npx create-next-app@latestTake the defaults so Tailwind, App Router, and @/* are set. src/ directory:
npx create-next-app@latest --src-dirThat puts the app in src/app and points @/* at ./src/*.
Alias
Skip if create-next-app already wrote this.
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}With --src-dir, use "./src/*".
Run init
npx shadcn@latest initAdd a component
npx shadcn@latest add https://www.shadcn.io/r/button.jsonimport { Button } from "@/components/ui/button"
export default function Home() {
return (
<div className="flex min-h-svh items-center justify-center">
<Button>Click me</Button>
</div>
)
}--src-dir → src/app/page.tsx.
Cannot find module '@/components/ui/button'
tsconfig.json needs "@/*": ["./*"] (or "./src/*"). Import globals.css in app/layout.tsx.
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Installation
How to install dependencies and structure your app. Official shadcn CLI, then add a component from the shadcn.io registry — Next.js, Vite, Laravel, and more.
Vite
Install shadcn/ui in a Vite React app with the official CLI. Tailwind v4, the @ alias, then add a component from the shadcn.io registry.