@tanstack/react-router 1.133.21 → 1.133.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/Match.cjs.map +1 -1
  2. package/dist/cjs/Match.d.cts +6 -0
  3. package/dist/cjs/Matches.cjs.map +1 -1
  4. package/dist/cjs/Matches.d.cts +42 -0
  5. package/dist/cjs/fileRoute.cjs.map +1 -1
  6. package/dist/cjs/fileRoute.d.cts +43 -0
  7. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  8. package/dist/cjs/lazyRouteComponent.d.cts +9 -0
  9. package/dist/cjs/link.cjs.map +1 -1
  10. package/dist/cjs/link.d.cts +12 -0
  11. package/dist/cjs/route.cjs.map +1 -1
  12. package/dist/cjs/route.d.cts +18 -0
  13. package/dist/cjs/useLoaderData.cjs.map +1 -1
  14. package/dist/cjs/useLoaderData.d.cts +11 -0
  15. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  16. package/dist/cjs/useLoaderDeps.d.cts +11 -0
  17. package/dist/cjs/useLocation.cjs.map +1 -1
  18. package/dist/cjs/useLocation.d.cts +11 -0
  19. package/dist/cjs/useMatch.cjs.map +1 -1
  20. package/dist/cjs/useMatch.d.cts +12 -0
  21. package/dist/cjs/useNavigate.cjs.map +1 -1
  22. package/dist/cjs/useNavigate.d.cts +8 -4
  23. package/dist/cjs/useRouter.cjs.map +1 -1
  24. package/dist/cjs/useRouter.d.cts +10 -0
  25. package/dist/esm/Match.d.ts +6 -0
  26. package/dist/esm/Match.js.map +1 -1
  27. package/dist/esm/Matches.d.ts +42 -0
  28. package/dist/esm/Matches.js.map +1 -1
  29. package/dist/esm/fileRoute.d.ts +43 -0
  30. package/dist/esm/fileRoute.js.map +1 -1
  31. package/dist/esm/lazyRouteComponent.d.ts +9 -0
  32. package/dist/esm/lazyRouteComponent.js.map +1 -1
  33. package/dist/esm/link.d.ts +12 -0
  34. package/dist/esm/link.js.map +1 -1
  35. package/dist/esm/route.d.ts +18 -0
  36. package/dist/esm/route.js.map +1 -1
  37. package/dist/esm/useLoaderData.d.ts +11 -0
  38. package/dist/esm/useLoaderData.js.map +1 -1
  39. package/dist/esm/useLoaderDeps.d.ts +11 -0
  40. package/dist/esm/useLoaderDeps.js.map +1 -1
  41. package/dist/esm/useLocation.d.ts +11 -0
  42. package/dist/esm/useLocation.js.map +1 -1
  43. package/dist/esm/useMatch.d.ts +12 -0
  44. package/dist/esm/useMatch.js.map +1 -1
  45. package/dist/esm/useNavigate.d.ts +8 -4
  46. package/dist/esm/useNavigate.js.map +1 -1
  47. package/dist/esm/useRouter.d.ts +10 -0
  48. package/dist/esm/useRouter.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/Match.tsx +6 -0
  51. package/src/Matches.tsx +43 -0
  52. package/src/fileRoute.ts +43 -0
  53. package/src/lazyRouteComponent.tsx +9 -0
  54. package/src/link.tsx +12 -0
  55. package/src/route.tsx +18 -0
  56. package/src/useLoaderData.tsx +11 -0
  57. package/src/useLoaderDeps.tsx +11 -0
  58. package/src/useLocation.tsx +11 -0
  59. package/src/useMatch.tsx +12 -0
  60. package/src/useNavigate.tsx +8 -4
  61. package/src/useRouter.tsx +10 -0
@@ -1 +1 @@
1
- {"version":3,"file":"useMatch.js","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow> {\n const nearestMatchId = React.useContext(\n opts.from ? dummyMatchContext : matchContext,\n )\n\n const matchSelection = useRouterState({\n select: (state: any) => {\n const match = state.matches.find((d: any) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n invariant(\n !((opts.shouldThrow ?? true) && !match),\n `Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n\n if (match === undefined) {\n return undefined\n }\n\n return opts.select ? opts.select(match) : match\n },\n structuralSharing: opts.structuralSharing,\n } as any)\n\n return matchSelection as any\n}\n"],"names":[],"mappings":";;;;AA6EO,SAAS,SAQd,MAQ6E;AAC7E,QAAM,iBAAiB,MAAM;AAAA,IAC3B,KAAK,OAAO,oBAAoB;AAAA,EAAA;AAGlC,QAAM,iBAAiB,eAAe;AAAA,IACpC,QAAQ,CAAC,UAAe;AACtB,YAAM,QAAQ,MAAM,QAAQ;AAAA,QAAK,CAAC,MAChC,KAAK,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,OAAO;AAAA,MAAA;AAEjD;AAAA,QACE,GAAG,KAAK,eAAe,SAAS,CAAC;AAAA,QACjC,kBAAkB,KAAK,OAAO,yBAAyB,KAAK,IAAI,MAAM,kBAAkB;AAAA,MAAA;AAG1F,UAAI,UAAU,QAAW;AACvB,eAAO;AAAA,MACT;AAEA,aAAO,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,KAAK;AAAA,EAAA,CAClB;AAER,SAAO;AACT;"}
1
+ {"version":3,"file":"useMatch.js","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\n/**\n * Read and select the nearest or targeted route match.\n *\n * Options:\n * - `from`/`strict`: Target a specific route ID and control union vs. exact typing\n * - `select`: Project the match object to a derived value\n * - `shouldThrow`: Throw if the match is not found in strict contexts\n * - `structuralSharing`: Enable structural sharing for stable references\n *\n * @returns The active match (or selected value).\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchHook\n */\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow> {\n const nearestMatchId = React.useContext(\n opts.from ? dummyMatchContext : matchContext,\n )\n\n const matchSelection = useRouterState({\n select: (state: any) => {\n const match = state.matches.find((d: any) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n invariant(\n !((opts.shouldThrow ?? true) && !match),\n `Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n\n if (match === undefined) {\n return undefined\n }\n\n return opts.select ? opts.select(match) : match\n },\n structuralSharing: opts.structuralSharing,\n } as any)\n\n return matchSelection as any\n}\n"],"names":[],"mappings":";;;;AAyFO,SAAS,SAQd,MAQ6E;AAC7E,QAAM,iBAAiB,MAAM;AAAA,IAC3B,KAAK,OAAO,oBAAoB;AAAA,EAAA;AAGlC,QAAM,iBAAiB,eAAe;AAAA,IACpC,QAAQ,CAAC,UAAe;AACtB,YAAM,QAAQ,MAAM,QAAQ;AAAA,QAAK,CAAC,MAChC,KAAK,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,OAAO;AAAA,MAAA;AAEjD;AAAA,QACE,GAAG,KAAK,eAAe,SAAS,CAAC;AAAA,QACjC,kBAAkB,KAAK,OAAO,yBAAyB,KAAK,IAAI,MAAM,kBAAkB;AAAA,MAAA;AAG1F,UAAI,UAAU,QAAW;AACvB,eAAO;AAAA,MACT;AAEA,aAAO,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,KAAK;AAAA,EAAA,CAClB;AAER,SAAO;AACT;"}
@@ -1,12 +1,16 @@
1
1
  import { AnyRouter, FromPathOption, NavigateOptions, RegisteredRouter, UseNavigateResult } from '@tanstack/router-core';
2
2
  /**
3
- * React hook that returns a `navigate` function for programmatic navigation.
4
- * Supports updating pathname, search, hash and state with full type-safety.
3
+ * Imperative navigation hook.
4
+ *
5
+ * Returns a stable `navigate(options)` function to change the current location
6
+ * programmatically. Prefer the `Link` component for user-initiated navigation,
7
+ * and use this hook from effects, callbacks, or handlers where imperative
8
+ * navigation is required.
5
9
  *
6
10
  * Options:
7
- * - `from`: Default base path used to resolve relative `to` destinations.
11
+ * - `from`: Optional route base used to resolve relative `to` paths.
8
12
  *
9
- * @returns A memoized `navigate` function.
13
+ * @returns A function that accepts `NavigateOptions`.
10
14
  * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook
11
15
  */
12
16
  export declare function useNavigate<TRouter extends AnyRouter = RegisteredRouter, TDefaultFrom extends string = string>(_defaultOpts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigate.js","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n FromPathOption,\n NavigateOptions,\n RegisteredRouter,\n UseNavigateResult,\n} from '@tanstack/router-core'\n\n/**\n * React hook that returns a `navigate` function for programmatic navigation.\n * Supports updating pathname, search, hash and state with full type-safety.\n *\n * Options:\n * - `from`: Default base path used to resolve relative `to` destinations.\n *\n * @returns A memoized `navigate` function.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook\n */\nexport function useNavigate<\n TRouter extends AnyRouter = RegisteredRouter,\n TDefaultFrom extends string = string,\n>(_defaultOpts?: {\n from?: FromPathOption<TRouter, TDefaultFrom>\n}): UseNavigateResult<TDefaultFrom> {\n const router = useRouter()\n\n return React.useCallback(\n (options: NavigateOptions) => {\n return router.navigate({\n ...options,\n from: options.from ?? _defaultOpts?.from,\n })\n },\n [_defaultOpts?.from, router],\n ) as UseNavigateResult<TDefaultFrom>\n}\n\n/**\n * Component that triggers a navigation when rendered. Navigation executes\n * in an effect after mount/update.\n *\n * Props are the same as `NavigateOptions` used by `navigate()`.\n *\n * @returns null\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/navigateComponent\n */\nexport function Navigate<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const router = useRouter()\n const navigate = useNavigate()\n\n const previousPropsRef = React.useRef<NavigateOptions<\n TRouter,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > | null>(null)\n React.useEffect(() => {\n if (previousPropsRef.current !== props) {\n navigate(props)\n previousPropsRef.current = props\n }\n }, [router, props, navigate])\n return null\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,YAGd,cAEkC;AAClC,QAAM,SAAS,UAAA;AAEf,SAAO,MAAM;AAAA,IACX,CAAC,YAA6B;AAC5B,aAAO,OAAO,SAAS;AAAA,QACrB,GAAG;AAAA,QACH,MAAM,QAAQ,QAAQ,cAAc;AAAA,MAAA,CACrC;AAAA,IACH;AAAA,IACA,CAAC,cAAc,MAAM,MAAM;AAAA,EAAA;AAE/B;AAWO,SAAS,SAMd,OAAuE;AACvE,QAAM,SAAS,UAAA;AACf,QAAM,WAAW,YAAA;AAEjB,QAAM,mBAAmB,MAAM,OAMrB,IAAI;AACd,QAAM,UAAU,MAAM;AACpB,QAAI,iBAAiB,YAAY,OAAO;AACtC,eAAS,KAAK;AACd,uBAAiB,UAAU;AAAA,IAC7B;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAC5B,SAAO;AACT;"}
1
+ {"version":3,"file":"useNavigate.js","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n FromPathOption,\n NavigateOptions,\n RegisteredRouter,\n UseNavigateResult,\n} from '@tanstack/router-core'\n\n/**\n * Imperative navigation hook.\n *\n * Returns a stable `navigate(options)` function to change the current location\n * programmatically. Prefer the `Link` component for user-initiated navigation,\n * and use this hook from effects, callbacks, or handlers where imperative\n * navigation is required.\n *\n * Options:\n * - `from`: Optional route base used to resolve relative `to` paths.\n *\n * @returns A function that accepts `NavigateOptions`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook\n */\nexport function useNavigate<\n TRouter extends AnyRouter = RegisteredRouter,\n TDefaultFrom extends string = string,\n>(_defaultOpts?: {\n from?: FromPathOption<TRouter, TDefaultFrom>\n}): UseNavigateResult<TDefaultFrom> {\n const router = useRouter()\n\n return React.useCallback(\n (options: NavigateOptions) => {\n return router.navigate({\n ...options,\n from: options.from ?? _defaultOpts?.from,\n })\n },\n [_defaultOpts?.from, router],\n ) as UseNavigateResult<TDefaultFrom>\n}\n\n/**\n * Component that triggers a navigation when rendered. Navigation executes\n * in an effect after mount/update.\n *\n * Props are the same as `NavigateOptions` used by `navigate()`.\n *\n * @returns null\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/navigateComponent\n */\nexport function Navigate<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const router = useRouter()\n const navigate = useNavigate()\n\n const previousPropsRef = React.useRef<NavigateOptions<\n TRouter,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > | null>(null)\n React.useEffect(() => {\n if (previousPropsRef.current !== props) {\n navigate(props)\n previousPropsRef.current = props\n }\n }, [router, props, navigate])\n return null\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,YAGd,cAEkC;AAClC,QAAM,SAAS,UAAA;AAEf,SAAO,MAAM;AAAA,IACX,CAAC,YAA6B;AAC5B,aAAO,OAAO,SAAS;AAAA,QACrB,GAAG;AAAA,QACH,MAAM,QAAQ,QAAQ,cAAc;AAAA,MAAA,CACrC;AAAA,IACH;AAAA,IACA,CAAC,cAAc,MAAM,MAAM;AAAA,EAAA;AAE/B;AAWO,SAAS,SAMd,OAAuE;AACvE,QAAM,SAAS,UAAA;AACf,QAAM,WAAW,YAAA;AAEjB,QAAM,mBAAmB,MAAM,OAMrB,IAAI;AACd,QAAM,UAAU,MAAM;AACpB,QAAI,iBAAiB,YAAY,OAAO;AACtC,eAAS,KAAK;AACd,uBAAiB,UAAU;AAAA,IAC7B;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAC5B,SAAO;AACT;"}
@@ -1,4 +1,14 @@
1
1
  import { AnyRouter, RegisteredRouter } from '@tanstack/router-core';
2
+ /**
3
+ * Access the current TanStack Router instance from React context.
4
+ * Must be used within a `RouterProvider`.
5
+ *
6
+ * Options:
7
+ * - `warn`: Log a warning if no router context is found (default: true).
8
+ *
9
+ * @returns The registered router instance.
10
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
11
+ */
2
12
  /**
3
13
  * Access the current TanStack Router instance from React context.
4
14
  * Must be used within a `RouterProvider`.
@@ -1 +1 @@
1
- {"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(getRouterContext())\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQ,MAAM,WAAW,iBAAA,CAAkB;AACjD;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;"}
1
+ {"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(getRouterContext())\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":[],"mappings":";;;AAyBO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQ,MAAM,WAAW,iBAAA,CAAkB;AACjD;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.133.21",
3
+ "version": "1.133.22",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/Match.tsx CHANGED
@@ -306,6 +306,12 @@ export const MatchInner = React.memo(function MatchInnerImpl({
306
306
  return out
307
307
  })
308
308
 
309
+ /**
310
+ * Render the next child match in the route tree. Typically used inside
311
+ * a route component to render nested routes.
312
+ *
313
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent
314
+ */
309
315
  export const Outlet = React.memo(function OutletImpl() {
310
316
  const router = useRouter()
311
317
  const matchId = React.useContext(matchContext)
package/src/Matches.tsx CHANGED
@@ -41,6 +41,10 @@ declare module '@tanstack/router-core' {
41
41
  }
42
42
  }
43
43
 
44
+ /**
45
+ * Internal component that renders the router's active match tree with
46
+ * suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
47
+ */
44
48
  export function Matches() {
45
49
  const router = useRouter()
46
50
  const rootRoute: AnyRoute = router.routesById[rootRouteId]
@@ -119,6 +123,18 @@ export type UseMatchRouteOptions<
119
123
  MaskOptions<TRouter, TMaskFrom, TMaskTo> &
120
124
  MatchRouteOptions
121
125
 
126
+ /**
127
+ * Create a matcher function for testing locations against route definitions.
128
+ *
129
+ * The returned function accepts standard navigation options (`to`, `params`,
130
+ * `search`, etc.) and returns either `false` (no match) or the matched params
131
+ * object when the route matches the current or pending location.
132
+ *
133
+ * Useful for conditional rendering and active UI states.
134
+ *
135
+ * @returns A `matchRoute(options)` function that returns `false` or params.
136
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook
137
+ */
122
138
  export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
123
139
  const router = useRouter()
124
140
 
@@ -169,6 +185,13 @@ export type MakeMatchRouteOptions<
169
185
  | React.ReactNode
170
186
  }
171
187
 
188
+ /**
189
+ * Component that conditionally renders its children based on whether a route
190
+ * matches the provided `from`/`to` options. If `children` is a function, it
191
+ * receives the matched params object.
192
+ *
193
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent
194
+ */
172
195
  export function MatchRoute<
173
196
  TRouter extends AnyRouter = RegisteredRouter,
174
197
  const TFrom extends string = string,
@@ -220,6 +243,22 @@ export function useMatches<
220
243
  } as any) as UseMatchesResult<TRouter, TSelected>
221
244
  }
222
245
 
246
+ /**
247
+ * Read the full array of active route matches or select a derived subset.
248
+ *
249
+ * Useful for debugging, breadcrumbs, or aggregating metadata across matches.
250
+ *
251
+ * @returns The array of matches (or the selected value).
252
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
253
+ */
254
+
255
+ /**
256
+ * Read the full array of active route matches or select a derived subset.
257
+ *
258
+ * Useful for debugging, breadcrumbs, or aggregating metadata across matches.
259
+ *
260
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
261
+ */
223
262
  export function useParentMatches<
224
263
  TRouter extends AnyRouter = RegisteredRouter,
225
264
  TSelected = unknown,
@@ -242,6 +281,10 @@ export function useParentMatches<
242
281
  } as any)
243
282
  }
244
283
 
284
+ /**
285
+ * Read the array of active route matches that are children of the current
286
+ * match (or selected parent) in the match tree.
287
+ */
245
288
  export function useChildMatches<
246
289
  TRouter extends AnyRouter = RegisteredRouter,
247
290
  TSelected = unknown,
package/src/fileRoute.ts CHANGED
@@ -35,6 +35,17 @@ import type { UseLoaderDepsRoute } from './useLoaderDeps'
35
35
  import type { UseLoaderDataRoute } from './useLoaderData'
36
36
  import type { UseRouteContextRoute } from './useRouteContext'
37
37
 
38
+ /**
39
+ * Creates a file-based Route factory for a given path.
40
+ *
41
+ * Used by TanStack Router's file-based routing to associate a file with a
42
+ * route. The returned function accepts standard route options. In normal usage
43
+ * the `path` string is inserted and maintained by the `tsr` generator.
44
+ *
45
+ * @param path File path literal for the route (usually auto-generated).
46
+ * @returns A function that accepts Route options and returns a Route instance.
47
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
48
+ */
38
49
  /**
39
50
  * Creates a file-based Route factory for a given path.
40
51
  *
@@ -66,6 +77,10 @@ export function createFileRoute<
66
77
  }).createRoute
67
78
  }
68
79
 
80
+ /**
81
+ @deprecated It's no longer recommended to use the `FileRoute` class directly.
82
+ Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
83
+ */
69
84
  /**
70
85
  @deprecated It's no longer recommended to use the `FileRoute` class directly.
71
86
  Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
@@ -159,6 +174,11 @@ export class FileRoute<
159
174
  }
160
175
  }
161
176
 
177
+ /**
178
+ @deprecated It's recommended not to split loaders into separate files.
179
+ Instead, place the loader function in the the main route file, inside the
180
+ `createFileRoute('/path/to/file)(options)` options.
181
+ */
162
182
  /**
163
183
  @deprecated It's recommended not to split loaders into separate files.
164
184
  Instead, place the loader function in the the main route file, inside the
@@ -264,6 +284,18 @@ export class LazyRoute<TRoute extends AnyRoute> {
264
284
  }
265
285
  }
266
286
 
287
+ /**
288
+ * Creates a lazily-configurable code-based route stub by ID.
289
+ *
290
+ * Use this for code-splitting with code-based routes. The returned function
291
+ * accepts only non-critical route options like `component`, `pendingComponent`,
292
+ * `errorComponent`, and `notFoundComponent` which are applied when the route
293
+ * is matched.
294
+ *
295
+ * @param id Route ID string literal to associate with the lazy route.
296
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
297
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
298
+ */
267
299
  /**
268
300
  * Creates a lazily-configurable code-based route stub by ID.
269
301
  *
@@ -289,6 +321,17 @@ export function createLazyRoute<
289
321
  }
290
322
  }
291
323
 
324
+ /**
325
+ * Creates a lazily-configurable file-based route stub by file path.
326
+ *
327
+ * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
328
+ * The returned function accepts only non-critical route options like
329
+ * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
330
+ *
331
+ * @param id File path literal for the route file.
332
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
333
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
334
+ */
292
335
  /**
293
336
  * Creates a lazily-configurable file-based route stub by file path.
294
337
  *
@@ -2,6 +2,15 @@ import * as React from 'react'
2
2
  import { isModuleNotFoundError } from '@tanstack/router-core'
3
3
  import type { AsyncRouteComponent } from './route'
4
4
 
5
+ /**
6
+ * Wrap a dynamic import to create a route component that supports
7
+ * `.preload()` and friendly reload-on-module-missing behavior.
8
+ *
9
+ * @param importer Function returning a module promise
10
+ * @param exportName Named export to use (default: `default`)
11
+ * @returns A lazy route component compatible with TanStack Router
12
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/lazyRouteComponentFunction
13
+ */
5
14
  export function lazyRouteComponent<
6
15
  T extends Record<string, any>,
7
16
  TKey extends keyof T = 'default',
package/src/link.tsx CHANGED
@@ -25,6 +25,18 @@ import type {
25
25
  ValidateLinkOptionsArray,
26
26
  } from './typePrimitives'
27
27
 
28
+ /**
29
+ * Build anchor-like props for declarative navigation and preloading.
30
+ *
31
+ * Returns stable `href`, event handlers and accessibility props derived from
32
+ * router options and active state. Used internally by `Link` and custom links.
33
+ *
34
+ * Options cover `to`, `params`, `search`, `hash`, `state`, `preload`,
35
+ * `activeProps`, `inactiveProps`, and more.
36
+ *
37
+ * @returns React anchor props suitable for `<a>` or custom components.
38
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLinkPropsHook
39
+ */
28
40
  export function useLinkProps<
29
41
  TRouter extends AnyRouter = RegisteredRouter,
30
42
  const TFrom extends string = string,
package/src/route.tsx CHANGED
@@ -78,6 +78,24 @@ declare module '@tanstack/router-core' {
78
78
  }
79
79
  }
80
80
 
81
+ /**
82
+ * Returns a route-specific API that exposes type-safe hooks pre-bound
83
+ * to a single route ID. Useful for consuming a route's APIs from files
84
+ * where the route object isn't directly imported (e.g. code-split files).
85
+ *
86
+ * @param id Route ID string literal for the target route.
87
+ * @returns A `RouteApi` instance bound to the given route ID.
88
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction
89
+ */
90
+ /**
91
+ * Returns a route-specific API that exposes type-safe hooks pre-bound
92
+ * to a single route ID. Useful for consuming a route's APIs from files
93
+ * where the route object isn't directly imported (e.g. code-split files).
94
+ *
95
+ * @param id Route ID string literal for the target route.
96
+ * @returns A `RouteApi` instance bound to the given route ID.
97
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction
98
+ */
81
99
  /**
82
100
  * Returns a route-specific API that exposes type-safe hooks pre-bound
83
101
  * to a single route ID. Useful for consuming a route's APIs from files
@@ -54,6 +54,17 @@ export type UseLoaderDataRoute<out TId> = <
54
54
  StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,
55
55
  ) => UseLoaderDataResult<TRouter, TId, true, TSelected>
56
56
 
57
+ /**
58
+ * Read and select the current route's loader data with type‑safety.
59
+ *
60
+ * Options:
61
+ * - `from`/`strict`: Choose which route's data to read and strictness
62
+ * - `select`: Map the loader data to a derived value
63
+ * - `structuralSharing`: Enable structural sharing for stable references
64
+ *
65
+ * @returns The loader data (or selected value) for the matched route.
66
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
67
+ */
57
68
  export function useLoaderData<
58
69
  TRouter extends AnyRouter = RegisteredRouter,
59
70
  const TFrom extends string | undefined = undefined,
@@ -40,6 +40,17 @@ export type UseLoaderDepsRoute<out TId> = <
40
40
  StructuralSharingOption<TRouter, TSelected, false>,
41
41
  ) => UseLoaderDepsResult<TRouter, TId, TSelected>
42
42
 
43
+ /**
44
+ * Read and select the current route's loader dependencies object.
45
+ *
46
+ * Options:
47
+ * - `from`: Choose which route's loader deps to read
48
+ * - `select`: Map the deps to a derived value
49
+ * - `structuralSharing`: Enable structural sharing for stable references
50
+ *
51
+ * @returns The loader deps (or selected value) for the matched route.
52
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
53
+ */
43
54
  export function useLoaderDeps<
44
55
  TRouter extends AnyRouter = RegisteredRouter,
45
56
  const TFrom extends string | undefined = undefined,
@@ -26,6 +26,17 @@ export type UseLocationResult<
26
26
  ? RouterState<TRouter['routeTree']>['location']
27
27
  : TSelected
28
28
 
29
+ /**
30
+ * Read the current location from the router state with optional selection.
31
+ * Useful for subscribing to just the pieces of location you care about.
32
+ *
33
+ * Options:
34
+ * - `select`: Project the `location` object to a derived value
35
+ * - `structuralSharing`: Enable structural sharing for stable references
36
+ *
37
+ * @returns The current location (or selected value).
38
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
39
+ */
29
40
  export function useLocation<
30
41
  TRouter extends AnyRouter = RegisteredRouter,
31
42
  TSelected = unknown,
package/src/useMatch.tsx CHANGED
@@ -75,6 +75,18 @@ export type UseMatchResult<
75
75
  : MakeRouteMatchUnion<TRouter>
76
76
  : TSelected
77
77
 
78
+ /**
79
+ * Read and select the nearest or targeted route match.
80
+ *
81
+ * Options:
82
+ * - `from`/`strict`: Target a specific route ID and control union vs. exact typing
83
+ * - `select`: Project the match object to a derived value
84
+ * - `shouldThrow`: Throw if the match is not found in strict contexts
85
+ * - `structuralSharing`: Enable structural sharing for stable references
86
+ *
87
+ * @returns The active match (or selected value).
88
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchHook
89
+ */
78
90
  export function useMatch<
79
91
  TRouter extends AnyRouter = RegisteredRouter,
80
92
  const TFrom extends string | undefined = undefined,
@@ -9,13 +9,17 @@ import type {
9
9
  } from '@tanstack/router-core'
10
10
 
11
11
  /**
12
- * React hook that returns a `navigate` function for programmatic navigation.
13
- * Supports updating pathname, search, hash and state with full type-safety.
12
+ * Imperative navigation hook.
13
+ *
14
+ * Returns a stable `navigate(options)` function to change the current location
15
+ * programmatically. Prefer the `Link` component for user-initiated navigation,
16
+ * and use this hook from effects, callbacks, or handlers where imperative
17
+ * navigation is required.
14
18
  *
15
19
  * Options:
16
- * - `from`: Default base path used to resolve relative `to` destinations.
20
+ * - `from`: Optional route base used to resolve relative `to` paths.
17
21
  *
18
- * @returns A memoized `navigate` function.
22
+ * @returns A function that accepts `NavigateOptions`.
19
23
  * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook
20
24
  */
21
25
  export function useNavigate<
package/src/useRouter.tsx CHANGED
@@ -3,6 +3,16 @@ import warning from 'tiny-warning'
3
3
  import { getRouterContext } from './routerContext'
4
4
  import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
5
5
 
6
+ /**
7
+ * Access the current TanStack Router instance from React context.
8
+ * Must be used within a `RouterProvider`.
9
+ *
10
+ * Options:
11
+ * - `warn`: Log a warning if no router context is found (default: true).
12
+ *
13
+ * @returns The registered router instance.
14
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
15
+ */
6
16
  /**
7
17
  * Access the current TanStack Router instance from React context.
8
18
  * Must be used within a `RouterProvider`.