MCPcopy
hub / github.com/TanStack/router / useRouter

Function useRouter

packages/react-router/src/useRouter.tsx:16–25  ·  view source on GitHub ↗
(opts?: {
  warn?: boolean
})

Source from the content-addressed store, hash-verified

14 * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
15 */
16export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
17 warn?: boolean
18}): TRouter {
19 const value = React.useContext(routerContext)
20 warning(
21 !((opts?.warn ?? true) && !value),
22 'useRouter must be used inside a <RouterProvider> component!',
23 )
24 return value as any
25}

Callers 15

useServerFnFunction · 0.90
TanStackRouterDevtoolsFunction · 0.90
HeadContentFunction · 0.90
ScriptsFunction · 0.90
useTagsFunction · 0.90
ScriptFunction · 0.90
RouteApiClass · 0.90
useLinkPropsFunction · 0.90
useRouterStateFunction · 0.90
LazyRouteClass · 0.90
TransitionerFunction · 0.90

Calls

no outgoing calls

Tested by 2

RootComponentFunction · 0.72
HeaderFunction · 0.72