TanStack Start

Install Constella in a TanStack Start 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.

Configure Vite

Install StyleX's Vite plugin:

Add it before the other plugins in vite.config.ts:

Set cssInjectionTarget. Without it, StyleX can pick a different CSS chunk in the client and server builds, and the stylesheet the HTML links has no styles. It matches src/styles.css, which builds to styles-[hash].css; change the prefix if yours has another name. enableDebugDataProp: false stops a hydration mismatch on data-style-src.

Import the base styles

Constella's theme, preflight and focus ring are in src/lib/constella/base.css. Import it at the top of src/styles.css, the stylesheet your root route links, so it applies at first paint:

Load styles in dev

In dev, StyleX serves its CSS separately. Load it in src/routes/__root.tsx:

Then render <DevStyleX /> in the root's <head>, after <HeadContent />.

Import components

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

Troubleshooting