@tanstack/react-router 1.133.19 → 1.133.21

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 (41) hide show
  1. package/dist/cjs/RouterProvider.cjs.map +1 -1
  2. package/dist/cjs/RouterProvider.d.cts +13 -0
  3. package/dist/cjs/fileRoute.cjs.map +1 -1
  4. package/dist/cjs/fileRoute.d.cts +23 -0
  5. package/dist/cjs/link.cjs.map +1 -1
  6. package/dist/cjs/link.d.cts +1 -1
  7. package/dist/cjs/route.cjs.map +1 -1
  8. package/dist/cjs/route.d.cts +9 -0
  9. package/dist/cjs/useParams.cjs.map +1 -1
  10. package/dist/cjs/useParams.d.cts +12 -0
  11. package/dist/cjs/useRouter.cjs.map +1 -1
  12. package/dist/cjs/useRouter.d.cts +10 -0
  13. package/dist/cjs/useRouterState.cjs.map +1 -1
  14. package/dist/cjs/useRouterState.d.cts +12 -0
  15. package/dist/cjs/useSearch.cjs.map +1 -1
  16. package/dist/cjs/useSearch.d.cts +12 -0
  17. package/dist/esm/RouterProvider.d.ts +13 -0
  18. package/dist/esm/RouterProvider.js.map +1 -1
  19. package/dist/esm/fileRoute.d.ts +23 -0
  20. package/dist/esm/fileRoute.js.map +1 -1
  21. package/dist/esm/link.d.ts +1 -1
  22. package/dist/esm/link.js.map +1 -1
  23. package/dist/esm/route.d.ts +9 -0
  24. package/dist/esm/route.js.map +1 -1
  25. package/dist/esm/useParams.d.ts +12 -0
  26. package/dist/esm/useParams.js.map +1 -1
  27. package/dist/esm/useRouter.d.ts +10 -0
  28. package/dist/esm/useRouter.js.map +1 -1
  29. package/dist/esm/useRouterState.d.ts +12 -0
  30. package/dist/esm/useRouterState.js.map +1 -1
  31. package/dist/esm/useSearch.d.ts +12 -0
  32. package/dist/esm/useSearch.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/RouterProvider.tsx +13 -0
  35. package/src/fileRoute.ts +23 -0
  36. package/src/link.tsx +1 -1
  37. package/src/route.tsx +9 -0
  38. package/src/useParams.tsx +12 -0
  39. package/src/useRouter.tsx +10 -0
  40. package/src/useRouterState.tsx +12 -0
  41. package/src/useSearch.tsx +12 -0
package/src/useParams.tsx CHANGED
@@ -61,6 +61,18 @@ export type UseParamsRoute<out TFrom> = <
61
61
  StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,
62
62
  ) => UseParamsResult<TRouter, TFrom, true, TSelected>
63
63
 
64
+ /**
65
+ * Access the current route's path parameters with type-safety.
66
+ *
67
+ * Options:
68
+ * - `from`/`strict`: Specify the matched route and whether to enforce strict typing
69
+ * - `select`: Project the params object to a derived value for memoized renders
70
+ * - `structuralSharing`: Enable structural sharing for stable references
71
+ * - `shouldThrow`: Throw if the route is not found in strict contexts
72
+ *
73
+ * @returns The params object (or selected value) for the matched route.
74
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
75
+ */
64
76
  export function useParams<
65
77
  TRouter extends AnyRouter = RegisteredRouter,
66
78
  const TFrom extends string | undefined = undefined,
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
  export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
7
17
  warn?: boolean
8
18
  }): TRouter {
@@ -28,6 +28,18 @@ export type UseRouterStateResult<
28
28
  TSelected,
29
29
  > = unknown extends TSelected ? RouterState<TRouter['routeTree']> : TSelected
30
30
 
31
+ /**
32
+ * Subscribe to the router's state store with optional selection and
33
+ * structural sharing for render optimization.
34
+ *
35
+ * Options:
36
+ * - `select`: Project the full router state to a derived slice
37
+ * - `structuralSharing`: Replace-equal semantics for stable references
38
+ * - `router`: Read state from a specific router instance instead of context
39
+ *
40
+ * @returns The selected router state (or the full state by default).
41
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook
42
+ */
31
43
  export function useRouterState<
32
44
  TRouter extends AnyRouter = RegisteredRouter,
33
45
  TSelected = unknown,
package/src/useSearch.tsx CHANGED
@@ -61,6 +61,18 @@ export type UseSearchRoute<out TFrom> = <
61
61
  StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,
62
62
  ) => UseSearchResult<TRouter, TFrom, true, TSelected>
63
63
 
64
+ /**
65
+ * Read and select the current route's search parameters with type-safety.
66
+ *
67
+ * Options:
68
+ * - `from`/`strict`: Control which route's search is read and how strictly it's typed
69
+ * - `select`: Map the search object to a derived value for render optimization
70
+ * - `structuralSharing`: Enable structural sharing for stable references
71
+ * - `shouldThrow`: Throw when the route is not found (strict contexts)
72
+ *
73
+ * @returns The search object (or selected value) for the matched route.
74
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
75
+ */
64
76
  export function useSearch<
65
77
  TRouter extends AnyRouter = RegisteredRouter,
66
78
  const TFrom extends string | undefined = undefined,