MCPcopy Create free account
hub / github.com/TanStack/router / useRouter

Function useRouter

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

Source from the content-addressed store, hash-verified

3import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
4
5export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
6 warn?: boolean
7}): TRouter {
8 const value = Solid.useContext(routerContext)
9 if (process.env.NODE_ENV !== 'production') {
10 if ((opts?.warn ?? true) && !value) {
11 console.warn(
12 'Warning: useRouter must be used inside a <RouterProvider> component!',
13 )
14 }
15 }
16 return value as TRouter
17}

Callers 15

TanStackRouterDevtoolsFunction · 0.90
ScriptsFunction · 0.90
useTagsFunction · 0.90
useCanGoBackFunction · 0.90
ScriptFunction · 0.90
CatchNotFoundFunction · 0.90
useMatchFunction · 0.90
RouteApiClass · 0.90
useLinkPropsFunction · 0.90
useRouterStateFunction · 0.90
LazyRouteClass · 0.90

Calls 1

warnMethod · 0.65

Tested by 3

RootComponentFunction · 0.72
HeaderFunction · 0.72
RouteErrorFunction · 0.72