# Install Keyframery in React Router (/docs/installation/react-router)

Add Keyframery's animated UI SDK components to a React Router framework-mode app with the shadcn CLI: a new project, a Create preset, or an existing app.

Choose the setup that matches your starting point.

- [Use Keyframery Create](#use-keyframery-create): Build your preset, then install it into a new React Router app.
- [Use the CLI](#use-the-cli): Scaffold a new React Router project from the terminal.
- [Existing Project](#existing-project): Add Keyframery to a React Router app you already have.

## Use Keyframery Create [#use-keyframery-create]

### Build your preset [#build-your-preset]

Open [Keyframery Create](/create) and pick your colours, corners, font and motion. Copy the command under the preview.

### Create the project [#create-the-project]

```bash
npx shadcn@latest init -t react-router
```

### Add the preset [#add-the-preset]

Run the command you copied from the project's folder:

```bash
npx shadcn@latest add @keyframery/preset-<code>
```

It writes the colours, corners and motion into `app/app.css`. A preset with a font installs it from Fontsource and imports it there too.

### Add components [#add-components]

```bash
npx shadcn@latest add @keyframery/tabs
```

Then [use it in a route](#use-it).

## Use the CLI [#use-the-cli]

### Create the project [#create-the-project-1]

```bash
npx shadcn@latest init -t react-router
```

For a project inside a monorepo, add `--monorepo`.

### Add components [#add-components-1]

```bash
npx shadcn@latest add @keyframery/tabs
```

The files land in `app/components/keyframery/`, and the motion tokens go into `app/app.css`.

### Use it [#use-it]

```tsx title="app/routes/home.tsx"
import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab } from "~/components/keyframery/tabs"

export default function Home() {
  return (
    <Tabs defaultValue="account">
      <TabsList aria-label="Settings">
        <TabsTab value="account">Account</TabsTab>
        <TabsTab value="password">Password</TabsTab>
      </TabsList>
      <TabsPanels>
        <TabsPanel value="account">Account settings</TabsPanel>
        <TabsPanel value="password">Password settings</TabsPanel>
      </TabsPanels>
    </Tabs>
  )
}
```

## Existing Project [#existing-project]

### Check the setup [#check-the-setup]

You need React 19, Tailwind CSS v4 and the `~/*` alias pointing at `app/`. Apps made with `create-react-router` have both. Then set up the CLI:

```bash
npx shadcn@latest init
```

### Add components [#add-components-2]

```bash
npx shadcn@latest add @keyframery/tabs
```

## Notes for React Router [#notes-for-react-router]

* **Imports.** Keyframery's files are written with `@/`. The CLI rewrites them to `~/` as it installs, so `react-router typegen && tsc` passes without edits.
* **Server rendering.** The components render on the server and start animating once the page hydrates.
* **Motion style.** Put `data-motion="calm"` on `<html>` in `app/root.tsx`, or wrap the `<Outlet />` in `<KeyframeryProvider motion="calm">`.

## Questions

### My app uses `~/` instead of `@/`. Do I change the imports?

No. The shadcn CLI reads the `~/` alias from `components.json` and rewrites every Keyframery import to match while it installs.

### Where do the files go?

Into `app/components/keyframery/`, with the shared motion helpers in `app/lib/keyframery.tsx` and the motion tokens in `app/app.css`.
