Glossário

Glossary — TanStack Router

addChildren() — Code-based routing function that composes a parent route and child routes into a nested route tree. (Ch 16, Ch 20)

Await component — Resolves a deferred (unawaited) promise from a loader by suspending until it settles, then renders children as a function receiving the resolved data. (Ch 37, Ch 56)

beforeLoad — Route option that runs before loader, serially from parent to child; used for auth guards, redirects, not-found checks, and extending route context. (Ch 36, Ch 49, Ch 50, Ch 51)

Basic Route — A route matching an exact static path (e.g. /about). (Ch 15)

createFileRoute(path) — Defines a route in file-based routing; the path string is auto-managed by the bundler plugin/CLI. (Ch 15, Ch 44)

createLazyFileRoute / createLazyRoute — Defines the non-critical (component, error/pending/not-found components) part of a route split into a .lazy.tsx file or code-based lazy module. (Ch 34)

createLink(Component) — Wraps a base component to produce a fully type-safe custom Link with the same prop interface as Link. (Ch 25)

createRootRoute() / createRootRouteWithContext<T>() — Creates the root route (no path, always matched); the WithContext variant types the router-wide context. (Ch 15, Ch 47, Ch 49)

createRoute() — Code-based routing function that manually defines a single route, requiring getParentRoute. (Ch 20)

createRouteMask() — Declaratively defines a route masking rule for use in routeMasks router config. (Ch 29)

createRouter() — Instantiates the Router object; requires a routeTree. (Ch 44)

Code-Based Routing — Building the route tree entirely in code via createRoute/addChildren, without filesystem conventions. Not recommended for most apps. (Ch 20)

Deferred promise — A promise returned unawaited from a loader, allowing the route to render before it resolves; consumed via Await or React's use(). (Ch 37)

Dynamic Segment ($param) — A path segment prefixed with $ that captures a URL part into params. (Ch 15, Ch 21, Ch 26)

Excluded Files (-prefix) — Files/folders prefixed with - are ignored by route generation, for colocating non-route logic. (Ch 15, Ch 21, Ch 57)

File-Based Routing — The recommended default routing method; routes are generated from the filesystem structure under routesDirectory. (Ch 18)

gcTime / preloadGcTime — Retention window (default 5 min) before unused cached loader data becomes eligible for garbage collection; preloadGcTime is the preload-specific variant. (Ch 36, Ch 40)

getParentRoute — Function each code-based route supplies to reference its parent, propagating type inference down the tree. (Ch 4, Ch 20, Ch 47)

getRouteApi(routeId) — Helper to access a route's type-safe hooks from a separate file without importing the Route object, avoiding circular imports. (Ch 34)

head route option — Returns title, meta, links, styles, scripts for a route, rendered via <HeadContent />. (Ch 41)

<HeadContent /> — Component rendered in the root layout's <head> that outputs the collected head tags from all matched routes. (Ch 41)

History (createBrowserHistory / createHashHistory / createMemoryHistory) — Pluggable history backends from @tanstack/history passed to createRouter({ history }). (Ch 31)

Index Route — Matches its parent route exactly when no child matches; declared with a trailing slash. (Ch 15)

Intent preloading — Preload strategy triggered on hover/touchstart of a <Link>. (Ch 40)

Layout Route — A route that wraps children with a shared component via <Outlet />. (Ch 15)

linkOptions() — Type-checks an object literal against Link/navigate/redirect option types eagerly, at definition time, returning it unchanged for reuse. (Ch 24)

loader — Route option that fetches data in parallel with route matching, backed by a built-in stale-while-revalidate cache. (Ch 36)

loaderDeps — Deterministic function extracting specific validated search params to include in a loader's cache key. (Ch 36)

Non-Nested Route (parent_.child) — A trailing underscore on a parent segment un-nests a route from the parent's component tree. (Ch 15, Ch 21)

notFound() — Function thrown inside beforeLoad/loader to signal a missing resource, rendering the nearest notFoundComponent. (Ch 50)

notFoundMode — Router option ('fuzzy' default or 'root') controlling which route's notFoundComponent renders for a not-found error. (Ch 50)

Optional Path Parameter ({-$param}) — A segment that may or may not be present in the URL; matches with the param as undefined when absent. (Ch 15, Ch 21, Ch 26, Ch 33)

<Outlet /> — Renders the next matching child route; rendered automatically when a route has no component. (Ch 45)

Pathless Layout Route (_prefix) — Wraps children without adding a URL segment; requires a unique route ID. (Ch 15, Ch 21)

Pathless Route Group ((group)) — A parenthesized directory that is purely organizational, not reflected in the URL. (Ch 15, Ch 21)

Preloading — Fetching a route's chunk/beforeLoad/loader before navigation, via intent, viewport, or render strategies. (Ch 40)

Register interface — TypeScript module-declaration-merging target (declare module '@tanstack/react-router' { interface Register { router: typeof router } }) that registers the router instance's type project-wide. (Ch 4, Ch 44, Ch 47)

redirect() — Function thrown (typically from beforeLoad) to perform a client-side navigation, commonly used for auth gating. (Ch 6, Ch 51, Ch 56)

Route Masking — Displays a different URL in the browser than the route actually navigated to, by storing the real location in history.state.__tempLocation. (Ch 29)

Route Matching / Route Sorting — The router's automatic sort of the route tree by specificity: index > static (most specific first) > dynamic (longest first) > splat. (Ch 17)

Route Tree — The hierarchical structure of routes, mapping directly to a nested component tree. (Ch 16)

routeTree.gen.ts — The generated route tree file, imported into the router and committed to version control since it is runtime source, not a disposable artifact. (Ch 6, Ch 7, Ch 57)

Scroll Restoration (scrollRestoration: true) — Router option that automatically caches and restores scroll positions across navigations, including nested scrollable containers. (Ch 32)

Search Middlewares — Functions of shape ({ search, next }) => result that transform search params whenever a link/href is generated. (Ch 27)

Search Params (validateSearch) — First-class, JSON-typed URL state validated by a route's validateSearch option (often via Zod/Valibot/ArkType). (Ch 27)

select (structural sharing) — Option on router-state hooks (useSearch, useRouterState, etc.) to subscribe to a computed subset of state; paired with structuralSharing: true to avoid re-renders from newly-computed but deep-equal objects. (Ch 43)

Splat/Catch-All Route ($) — A route whose path is $ alone, capturing the rest of the URL into params._splat. (Ch 15)

staleTime / preloadStaleTime — Milliseconds a route's loaded data is considered fresh; preloadStaleTime (default 30s) is the separate preload-specific freshness window. (Ch 36, Ch 40)

staticData — Arbitrary, synchronous metadata attached to a route at definition time, accessible via match.staticData/useMatches(). (Ch 52)

Streaming SSR — SSR mode that sends the critical first paint immediately and streams remaining (including deferred) content incrementally. (Ch 42)

Structural sharing — Preserving referential stability of unchanged parts of URL-derived state (e.g. unchanged search params) across re-renders. (Ch 43)

throw redirect() / throw notFound() — The throwable flow-control pattern for navigation and missing-resource signaling, requiring an ESLint only-throw-error allowlist. (Ch 50, Ch 51, Ch 54)

useBlocker() / <Block> — Registers a blocker function to pause or cancel a router-controlled navigation, e.g. to confirm discarding unsaved changes. (Ch 30)

useMatchRoute / router.matchRoute — Checks whether a route is currently matched or pending; useMatchRoute subscribes (for rendering), router.matchRoute is a one-off check (for event handlers). (Ch 23)

useMatches() — Returns all currently matched routes, each exposing its own staticData/context, used for breadcrumbs and layout composition. (Ch 49, Ch 52)

useNavigate({ from }) — Returns an imperative navigate function, intended for side-effect-driven navigation rather than user-clickable links. (Ch 23)

useSearch() / Route.useSearch() — Reads validated search params; the router-wide useSearch requires a from hint or strict: false. (Ch 27, Ch 47)

Validate* type utilities (ValidateLinkOptions, ValidateLinkOptionsArray, ValidateRedirectOptions, ValidateNavigateOptions, ValidateFromPath) — Stable, externally-focused type utilities for type-checking navigation props in custom wrapper components. (Ch 48)

Virtual File Routes — Programmatically declaring a route tree (via rootRoute, route, index, layout, physical from @tanstack/virtual-file-routes) that still maps to real route files on disk. (Ch 19)