Next.js

Install Constella in a Next.js app.

View as Markdown

With an agent

Paste this into your coding agent. It adapts the steps below to your project.

Add the registry

Add registries to your components.json. If you don't have one, create it:

Don't run shadcn init. It sets up Tailwind, which these components don't use.

Add components

The first one also adds StyleX and src/lib/constella: the tokens, the CSS they read, and theme.stylex.ts, the file you edit to theme Constella.

Set the @/* alias in tsconfig.json. StyleX's config below needs the same one, since StyleX and TypeScript resolve imports separately. The steps assume a src folder; without one, drop src/ from every path.

Configure StyleX

Install StyleX's Babel and PostCSS plugins:

Add babel.config.js to the project root:

Add postcss.config.js beside it, reusing the Babel plugins:

In src/app/globals.css, which the root layout already imports, import Constella's theme, preflight and focus ring at the top, and end with the directive StyleX replaces with its CSS:

Use Next.js 16.0.3 or later with Turbopack. Earlier versions only pick up babel.config.js with Webpack.

Import components

Then set up fonts, dark mode and, if you need it, RTL.

Troubleshooting