Back to InstallationYou are on Next.js.

Create a Next.js app with the registry, or wire the animated primitives into the app you already have.

ReactMeta-frameworksApp Router, Server Components and Tailwind v4.

Prerequisites

You need Next.js with React 19, Tailwind CSS v4 and an import alias. The CLI reads components.json to know where components, hooks and the cn helper live.

  • Node.js 20 or newer, with the package manager you already use.
  • React 19: the components pass ref as a regular prop.
  • Tailwind CSS v4: the stylesheet starts with @import "tailwindcss";.
  • An alias, @/* or ~/*, declared in tsconfig.json and resolved by the bundler.

New app or existing app

The starter ships the App Router, TypeScript, Tailwind CSS v4 and the @/* alias. With --src-dir the app lives in src/app and the alias points at ./src/*.

Create a Next.js app

npx create-next-app@latest my-app
npmthe default on every machine

Already have an app? Skip the scaffold, check the alias and Tailwind build, then continue at Configuration.

Configuration

Point the alias at the folder that holds your source. Then wrap the app once so every primitive shares the same tempo and reduced-motion policy. The registry installs motion and lucide-react with the first component, so an explicit install is optional.

Install the dependencies yourself (optional)

npm install motion lucide-react
npmthe default on every machine
tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
app/providers.tsx
"use client";

import { PrequelMotionProvider } from "@/components/prequelui/motion";

export function Providers({ children }: { children: React.ReactNode }) {
  return <PrequelMotionProvider tempo={1}>{children}</PrequelMotionProvider>;
}
app/layout.tsx
import { Providers } from "./providers";
import "./globals.css";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}
app/globals.css
@import "tailwindcss";

The provider imports the shared motion file that the first add writes. Run the next step before starting the dev server, or skip the provider and let each component use its own defaults.

Add a component

Run init once if the project has no components.json yet, then add the dialog. The file lands in components/prequelui and imports the shared motion helpers from the same folder.

Create components.json and the theme

npx shadcn@latest init
npmthe default on every machine

Add the animated component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/dialog.json
npmthe default on every machine
app/page.tsx
import { Dialog } from "@/components/prequelui/dialog";

export default function Home() {
  return (
    <main className="grid min-h-svh place-items-center">
      <Dialog trigger="Open dialog" title="Project overview" />
    </main>
  );
}

The add command writes the animated component and its shared motion helpers. Your markup stays yours: edit the installed file in place.

Dark mode

The Next.js starter already uses next-themes. In an existing app, install it and wrap the body; the provider sets the class before React hydrates.

Install the runtime

npm install next-themes
npmthe default on every machine
app/layout.tsx
import { ThemeProvider } from "next-themes";
import { Providers } from "./providers";
import "./globals.css";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
          <Providers>{children}</Providers>
        </ThemeProvider>
      </body>
    </html>
  );
}

Verification

Import the component, open it, and check the motion rather than only the markup.

  • The dialog opens with a veil and a small scale-and-blur entrance.
  • Press Escape and the surface leaves faster than it arrived.
  • Toggle the theme; the surface uses your theme variables, not hard-coded colours.
  • Turn on the system reduced-motion setting; the overlay still changes state, without travel.

Start the dev server

npm run dev
npmthe default on every machine

More React guides

All frameworks

Built by Vidhal. The source is available on GitHub.

MIT licensed