一键导入
tanstack-router
TanStack Router patterns for routing, navigation, search params, and layouts. Use when creating routes, navigating, or working with URL state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
TanStack Router patterns for routing, navigation, search params, and layouts. Use when creating routes, navigating, or working with URL state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Reproduce a research paper / white paper / arXiv result as a Tangle pipeline. Use when the user asks to "reproduce", "replicate", or "implement" a paper, benchmark, or arXiv link as an experiment.
Drive the open-source Tangle CLI (`tangle-cli`) via Bash for local pipeline/component workflows and API-backed run submission, status, logs, and artifacts. Use whenever an agent needs to validate, hydrate, submit, inspect, or debug Tangle pipelines and runs from the command line.
Answer Tangle product, docs, and how-to questions from a local RAG over the TangleML documentation. Use for conceptual / "what is" / "how do I" lookups, not live run or execution data.
Comprehensive Reveal.js reference for building HTML slide decks. Use whenever the user wants to create, revise, or extend a presentation, slide deck, or talk — especially from Markdown — including transitions, Auto-Animate, Mermaid diagrams, animatable SVG, video, backgrounds, fragments, code highlighting, speaker notes, math, themes, configuration, and PDF export.
Gather, vet, and cite sources for a research question. Use when answering factual questions, comparing options, or producing an evidence-backed write-up.
Builds simple standalone HTML page pieces with embedded CSS and playful animated SVG illustrations. Use when the user asks to create, revise, or extend an HTML page, landing page, invite, card, section, mockup, or visual web snippet.
| name | tanstack-router |
| description | TanStack Router patterns for routing, navigation, search params, and layouts. Use when creating routes, navigating, or working with URL state. |
This project uses code-based routing (not file-based) with TanStack Router v1.
Routes are defined in apps/web/src/routes/routeTree.tsx with createRootRoute / createRoute,
then assembled with addChildren. A pathless layout route (id: "app") renders the persistent
AppShell around every page:
const rootRoute = createRootRoute({
component: RootLayout,
notFoundComponent: NotFoundPage,
});
const appLayoutRoute = createRoute({
getParentRoute: () => rootRoute,
id: "app",
component: AppLayout, // <AppShell topBar={<AppTopNav />}><Outlet /></AppShell>
});
const sessionsRoute = createRoute({
getParentRoute: () => appLayoutRoute,
path: "/sessions",
component: SessionsPage,
});
export const routeTree = rootRoute.addChildren([
appLayoutRoute.addChildren([
indexRoute, // path "/" → redirect to "/sessions"
sessionsRoute,
sessionChatRoute, // "/sessions/$sessionId"
agentBundlesRoute, // "/agent-bundles"
globalMemoryRoute, // "/global-memory"
...(env.isDev ? [bundleUiHarnessRoute] : []), // dev-only "/bundle-ui-harness"
]),
]);
Paths are plain string literals on each route — there is no APP_ROUTES constant. Routes
conditionally mounted for dev use env.isDev from @/shared/config/env.
apps/web/src/routes/router.tsx creates the router. It mounts under the proxy sub-path via
BASE_PREFIX (from @/shared/lib/basePath) so client routing resolves behind the tangle pod-proxy:
export const router = createRouter({
routeTree,
history: createBrowserHistory(),
basepath: BASE_PREFIX,
defaultPreload: "intent", // preload on hover/focus
});
Use beforeLoad for redirects and simple param extraction (this project does not use route
loaders — fetch with query hooks in components instead):
const indexRoute = createRoute({
getParentRoute: () => appLayoutRoute,
path: "/",
beforeLoad: () => {
throw redirect({ to: "/sessions" });
},
});
const navigate = useNavigate();
navigate({ to: "/sessions/$sessionId", params: { sessionId } });
For nav links, use the design-system TopNav / TopNavLink patterns (which wrap the router Link)
rather than styling a raw Link — remember the no-className-on-primitives rule:
import { Link } from "@tanstack/react-router";
import { TopNav, TopNavLink } from "@/shared/ui/patterns/top-nav";
<TopNav
brand={
<Link to="/sessions">
<Text size="lg" weight="bold">
Tangent Shell
</Text>
</Link>
}
links={
<>
<TopNavLink to="/sessions">Sessions</TopNavLink>
<TopNavLink to="/agent-bundles">Agent bundles</TopNavLink>
</>
}
/>;
Read typed params with the from option pointing at the route's full path id:
const { sessionId } = useParams({ from: "/app/sessions/$sessionId" });
For query/search state, use useSearch. Validate with type guards, not Zod, and read
loosely-typed search with useSearch({ strict: false }) when a route doesn't declare a
validateSearch. Keep dynamic values (ids, counts) in params/search, not in path constants.
| Hook | Use case |
|---|---|
useNavigate() | Programmatic navigation |
useParams({ from }) | Route params ($sessionId) |
useSearch({ strict: false }) | Search/query params |
useLocation() | Current pathname |
useRouter() / useRouterState() | Router instance / advanced state |
Layouts render <Outlet /> for children. The current tree:
rootRoute (RootLayout, notFoundComponent: NotFoundPage)
└── appLayoutRoute (AppLayout: AppShell + AppTopNav + Outlet)
├── indexRoute "/" → redirect "/sessions"
├── sessionsRoute "/sessions"
├── sessionChatRoute "/sessions/$sessionId"
├── agentBundlesRoute "/agent-bundles"
├── globalMemoryRoute "/global-memory"
└── bundleUiHarnessRoute "/bundle-ui-harness" (dev only)