Back to InstallationYou are on TanStack Start.
Installation

TanStack Start

The components drop into a file route or a server function's view without a client-only wrapper.

ReactMeta-frameworksFile routes, server functions and SSR on Vite.

Prerequisites

You need TanStack Start 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

Choose TanStack Start with React and keep Tailwind on. The starter uses file routes, server functions, Vite and the @/* alias.

Create a TanStack Start app

npx @tanstack/cli@latest create
npmthe default on every machine

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

Configuration

Vite resolves @/* through the tsconfig paths plugin. Wrap the root route's shell with the provider so server rendering and hydration share the same motion configuration.

Install the dependencies yourself (optional)

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

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

export function Providers({ children }: { children: React.ReactNode }) {
  return <PrequelMotionProvider tempo={1}>{children}</PrequelMotionProvider>;
}
vite.config.ts
import tailwindcss from "@tailwindcss/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [tsconfigPaths(), tailwindcss(), tanstackStart(), react()],
});
src/styles.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
src/routes/index.tsx
import { createFileRoute } from "@tanstack/react-router";
import { Dialog } from "@/components/prequelui/dialog";

export const Route = createFileRoute("/")({ component: Home });

function Home() {
  return (
    <div className="grid min-h-svh place-items-center">
      <Dialog trigger="Open dialog" title="A server-rendered route" />
    </div>
  );
}

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

Dark mode

Set the class before the page paints. A small inline script in the root route's head reads the saved choice, so the first frame is already correct.

src/routes/__root.tsx
function RootDocument({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <script
          dangerouslySetInnerHTML={{
            __html: `try {
              const saved = localStorage.getItem("theme");
              const dark = saved === "dark" || (!saved && matchMedia("(prefers-color-scheme: dark)").matches);
              document.documentElement.classList.toggle("dark", dark);
            } catch {}`,
          }}
        />
      </head>
      <body>{children}</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