About
A layout wrapper that animates transitions between pages of a TanStack Router app using the browser's View Transitions API, with multiple built-in transition effects and shared-element morphing.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Page Transition (TanStack Router) to your project and fits it to your theme.
Code
How Page Transition (TanStack Router) is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import { PageTransition } from "@/components/ui/page-transition-tanstack-router";
import {
createRootRoute,
createRoute,
createRouter,
createMemoryHistory,
RouterProvider,
Link,
Outlet,
} from "@tanstack/react-router";
function RootLayout() {
return (
<div className="w-full max-w-md overflow-hidden rounded-xl border bg-background">
<nav className="flex gap-1 border-b p-2">
<Link
to="/"
className="rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-accent [&.active]:text-foreground"
>
Home
</Link>
<Link
to="/about"
className="rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-accent [&.active]:text-foreground"
>
About
</Link>
</nav>
<PageTransition
effect="slide"
className="relative flex h-64 flex-col justify-end gap-1.5 bg-background p-6"
>
<Outlet />
</PageTransition>
</div>
);
}
const rootRoute = createRootRoute({ component: RootLayout });
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/",
component: () => (
<>
<h2 className="text-2xl font-medium">Home</h2>
<p className="text-sm text-muted-foreground">
Animated page transitions for TanStack Router, built on view
transitions.
</p>
</>
),
});
const aboutRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/about",
component: () => (
<>
<h2 className="text-2xl font-medium">About</h2>
<p className="text-sm text-muted-foreground">
Swap pages and the transition plays automatically.
</p>
</>
),
});
const routeTree = rootRoute.addChildren([indexRoute, aboutRoute]);
const router = createRouter({
routeTree,
history: createMemoryHistory({ initialEntries: ["/"] }),
defaultViewTransition: true,
});
export default function PageTransitionTanstackRouterDemo() {
return (
<div className="flex w-full items-center justify-center p-8">
<RouterProvider router={router} />
</div>
);
}















