Skip to content

Guides

Next.js

Use DavinciUI with the App Router, server components, and the shadcn CLI.

DavinciUI works in both the App Router and the Pages Router. The App Router is the default in new Next.js projects, and most components are server-safe until you interact with them.

Configure the CLI#

Add the registry to components.json at the project root:

components.json
{
  "registries": {
    "@davinciui": "https://davinciui.com/r/{name}.json"
  }
}
Path aliases

Keep the @/* alias in tsconfig.json. The CLI uses it to decide where copied files land.

Server and client boundaries#

Components that use state, effects, or browser APIs include "use client" in their copied source. Import them from a client component, or let Next.js create the boundary for you.

app/page.tsx
import { Button } from "@/components/ui/button"
 
export default function Page() {
  return <Button>Server-rendered button</Button>
}

Motion and hydration#

Animated components run after hydration. Avoid rendering them inside a server component that expects static HTML only; wrap the interactive part in a client component.

Add the component

Run the CLI add command from the project root.

Check the directive

Open the copied file and confirm whether it starts with "use client".

Verify the build

Run next build and check for hydration warnings.

© DavinciUI