Getting started
Add docs to a Next.js project that uses shadcn/ui, with one shadcn CLI command.
docscn supports Next.js projects that use shadcn/ui with Base UI (the base-* styles).
Create a project
If you don't have a project yet, create one with shadcn/ui and Base UI:
npx shadcn@latest init --template=next --base=baseInstall the docs block
docscn is listed in the shadcn/ui registry index, so the CLI finds @docscn items without any setup. The docs block installs every docscn component, plus everything a docs site needs:
lib/source.ts: loadscontent/docswith Fumadocs MDXlib/layout.shared.tsx: shared layout options (title, links, GitHub URL)components/mdx.tsx: the MDX componentsapp/docs/layout.tsxandapp/docs/[[...slug]]/page.tsx: the docs routesapp/api/search/route.ts: the search APIcontent/docs/index.mdxandmeta.json: a first page
npx shadcn@latest add @docscn/docsFumadocs MDX depends on esbuild, and pnpm 11 won't install a package with an
install script until you decide whether it may run. If the install stops with
ERR_PNPM_IGNORED_BUILDS, pnpm has added a placeholder line, esbuild: set this to true or false, under allowBuilds in pnpm-workspace.yaml. Change
it to esbuild: false (esbuild works without its script) and run the command
again.
Finish the setup
Two files need small edits the CLI can't make for you.
Wrap your app in RootProvider. It includes next-themes, so it replaces the ThemeProvider from shadcn/ui's template or dark mode guide:
import { RootProvider } from "@/components/docs/provider/next";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<RootProvider>{children}</RootProvider> {}
</body>
</html>
);
}Compile MDX with Fumadocs MDX:
import { createMDX } from "fumadocs-mdx/next";
import type { NextConfig } from "next";
const nextConfig: NextConfig = {};
export default createMDX()(nextConfig); Run it
Start the dev server and open localhost:3000/docs:
npm run devWrite pages as .mdx files in content/docs, and order them with meta.json. See the Fumadocs docs for the page and meta.json conventions.
Install components one by one
You can also install components individually, for example:
npx shadcn@latest add @docscn/docs-layout @docscn/docs-page @docscn/mdxEach component lists the shadcn/ui primitives and other docscn components it needs, and the CLI installs them too. See the component pages for what each one does.
Monorepos
In a shadcn/ui monorepo, run the commands on this page in your app's directory (for example apps/web). docscn's components install into the app, and the shadcn/ui primitives they use into the shared packages/ui.
Two extra steps work around bugs in the shadcn CLI.
Before you install docscn, add the sidebar from packages/ui. Installed from the app, the CLI puts the sidebar's use-mobile hook in the app, where the sidebar can't import it (shadcn-ui/ui#12212):
npx shadcn@latest add sidebarAfter you install docscn, add its dependencies to your app. The CLI adds them to packages/ui/package.json only, so the app can't import them (shadcn-ui/ui#12213). Run these in your app's directory:
npm install @base-ui/react @fuma-translate/react@^1.0.2 class-variance-authority cn fumadocs-core@^16.17.8 fumadocs-mdx@^15.4.10 lucide-react next-themes react-medium-image-zoom scroll-into-view-if-needed shiki@^4.6.0npm install -D @types/mdxThese are the packages the docs block needs. The AI chat needs these too:
npm install @ai-sdk/react@^4.0.0 ai@^7.0.0 @openrouter/ai-sdk-provider@^3.1.0 flexsearch@^0.8.212 remark@^15.0.1 remark-gfm@^4.0.1 remark-rehype@^11.1.2 remend@^1.4.0 zod@^4.6.6npm install -D @types/hastIf you install components one by one, add the packages the CLI added to packages/ui/package.json instead. You can also delete the unused hooks/use-mobile.ts the CLI adds to your app.