cnippet/ui
  1. docs
  2. installation
  3. next

guides

Next.js

Install and configure cnippet ui in a Next.js project.

cnippet ui is installed with the shadcn CLI. The @cnippet registry is built in, so there is nothing to configure before you add components.

Create a project

If you already have a Next.js app, skip this step.

Choose the recommended defaults. They set up Tailwind CSS v4, the App Router and the @/* import alias. If you choose a src/ directory, the alias points to ./src/* instead.

Check the import alias

If you're adding cnippet ui to an older or custom app, make sure Tailwind CSS v4 is installed (guide) and tsconfig.json has the @/* alias:

tsconfig.json

Run the CLI

This creates components.json, adds lib/utils.ts and sets up the CSS variables in app/globals.css. Accept the defaults when prompted.

Add the cnippet ui theme

This replaces the default colors with the cnippet ui tokens and adds the info, success and warning colors that components like Alert, Badge and Toast use. See Colors for every token.

Add components

The component is added to components/ui/button.tsx. Import it like this:

app/page.tsx

Install everything at once

To set up the full theme (colors, fonts, sidebar and chart tokens, base styles) and every component in one command, run init with the cnippet ui style instead of the steps above:

Server Components

Every component file starts with "use client", so you can import them from Server Components without adding the directive yourself. Pass only serializable props (strings, numbers, JSX) from a Server Component. Event handlers like onClick need a Client Component.

Next steps