@tanstack/react-router 1.133.27 → 1.133.28
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.
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/ClientOnly.d.cts +5 -0
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.d.cts +9 -0
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +12 -0
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +9 -0
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.d.cts +4 -0
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +4 -0
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +5 -0
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +23 -0
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +14 -0
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +5 -0
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +4 -0
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +4 -0
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useLocation.d.cts +5 -0
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +0 -8
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +4 -0
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouter.d.cts +5 -0
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useRouterState.d.cts +5 -0
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +4 -0
- package/dist/esm/ClientOnly.d.ts +5 -0
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.d.ts +9 -0
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Matches.d.ts +12 -0
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +9 -0
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.d.ts +4 -0
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +4 -0
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/awaited.d.ts +5 -0
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +23 -0
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/link.d.ts +14 -0
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/router.d.ts +5 -0
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +4 -0
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +4 -0
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.d.ts +5 -0
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.d.ts +0 -8
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.d.ts +4 -0
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouter.d.ts +5 -0
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.d.ts +5 -0
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +4 -0
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/llms/rules/installation.d.ts +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/setup-and-architecture.d.ts +1 -1
- package/dist/llms/rules/setup-and-architecture.js +7 -7
- package/package.json +3 -3
- package/src/ClientOnly.tsx +8 -0
- package/src/HeadContent.tsx +9 -0
- package/src/Matches.tsx +12 -0
- package/src/RouterProvider.tsx +9 -0
- package/src/ScriptOnce.tsx +4 -0
- package/src/Scripts.tsx +4 -0
- package/src/awaited.tsx +5 -0
- package/src/fileRoute.ts +23 -0
- package/src/link.tsx +15 -0
- package/src/router.ts +5 -0
- package/src/useLoaderData.tsx +4 -0
- package/src/useLoaderDeps.tsx +4 -0
- package/src/useLocation.tsx +5 -0
- package/src/useMatch.tsx +0 -8
- package/src/useParams.tsx +4 -0
- package/src/useRouter.tsx +5 -0
- package/src/useRouterState.tsx +5 -0
- package/src/useSearch.tsx +4 -0
package/src/fileRoute.ts
CHANGED
|
@@ -57,6 +57,13 @@ import type { UseRouteContextRoute } from './useRouteContext'
|
|
|
57
57
|
* @returns A function that accepts Route options and returns a Route instance.
|
|
58
58
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
59
59
|
*/
|
|
60
|
+
/**
|
|
61
|
+
* Creates a file-based Route factory for a given path.
|
|
62
|
+
* Used by file-based routing to associate a file with a route. The returned
|
|
63
|
+
* function accepts standard route options; the path is typically auto-managed
|
|
64
|
+
* by the generator.
|
|
65
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
66
|
+
*/
|
|
60
67
|
export function createFileRoute<
|
|
61
68
|
TFilePath extends keyof FileRoutesByPath,
|
|
62
69
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
@@ -85,6 +92,10 @@ export function createFileRoute<
|
|
|
85
92
|
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
86
93
|
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
87
94
|
*/
|
|
95
|
+
/**
|
|
96
|
+
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
97
|
+
Instead, use `createFileRoute('/path')(options)` to create a file route.
|
|
98
|
+
*/
|
|
88
99
|
export class FileRoute<
|
|
89
100
|
TFilePath extends keyof FileRoutesByPath,
|
|
90
101
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
@@ -184,6 +195,10 @@ export class FileRoute<
|
|
|
184
195
|
Instead, place the loader function in the the main route file, inside the
|
|
185
196
|
`createFileRoute('/path/to/file)(options)` options.
|
|
186
197
|
*/
|
|
198
|
+
/**
|
|
199
|
+
@deprecated It's recommended not to split loaders into separate files.
|
|
200
|
+
Instead, place the loader function in the main route file via `createFileRoute`.
|
|
201
|
+
*/
|
|
187
202
|
export function FileRouteLoader<
|
|
188
203
|
TFilePath extends keyof FileRoutesByPath,
|
|
189
204
|
TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],
|
|
@@ -308,6 +323,10 @@ export class LazyRoute<TRoute extends AnyRoute> {
|
|
|
308
323
|
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
309
324
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
310
325
|
*/
|
|
326
|
+
/**
|
|
327
|
+
* Create a lazily-configurable code-based route stub by ID.
|
|
328
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
329
|
+
*/
|
|
311
330
|
export function createLazyRoute<
|
|
312
331
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
313
332
|
TId extends string = string,
|
|
@@ -343,6 +362,10 @@ export function createLazyRoute<
|
|
|
343
362
|
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
344
363
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
345
364
|
*/
|
|
365
|
+
/**
|
|
366
|
+
* Create a lazily-configurable file-based route stub by file path.
|
|
367
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
368
|
+
*/
|
|
346
369
|
export function createLazyFileRoute<
|
|
347
370
|
TFilePath extends keyof FileRoutesByPath,
|
|
348
371
|
TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],
|
package/src/link.tsx
CHANGED
|
@@ -615,6 +615,21 @@ export type LinkOptionsFn<TComp> = <
|
|
|
615
615
|
options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,
|
|
616
616
|
) => TOptions
|
|
617
617
|
|
|
618
|
+
/**
|
|
619
|
+
* Validate and reuse navigation options for `Link`, `navigate` or `redirect`.
|
|
620
|
+
* Accepts a literal options object and returns it typed for later spreading.
|
|
621
|
+
* @example
|
|
622
|
+
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
|
|
623
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
|
|
624
|
+
*/
|
|
618
625
|
export const linkOptions: LinkOptionsFn<'a'> = (options) => {
|
|
619
626
|
return options as any
|
|
620
627
|
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Type-check a literal object for use with `Link`, `navigate` or `redirect`.
|
|
631
|
+
* Use to validate and reuse navigation options across your app.
|
|
632
|
+
* @example
|
|
633
|
+
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
|
|
634
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
|
|
635
|
+
*/
|
package/src/router.ts
CHANGED
|
@@ -88,6 +88,11 @@ declare module '@tanstack/router-core' {
|
|
|
88
88
|
* @returns A Router instance to be provided to `RouterProvider`.
|
|
89
89
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
90
90
|
*/
|
|
91
|
+
/**
|
|
92
|
+
* Create a new React router instance from `RouterOptions`.
|
|
93
|
+
* Pass the resulting router to `RouterProvider`.
|
|
94
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
95
|
+
*/
|
|
91
96
|
export const createRouter: CreateRouterFn = (options) => {
|
|
92
97
|
return new Router(options)
|
|
93
98
|
}
|
package/src/useLoaderData.tsx
CHANGED
|
@@ -65,6 +65,10 @@ export type UseLoaderDataRoute<out TId> = <
|
|
|
65
65
|
* @returns The loader data (or selected value) for the matched route.
|
|
66
66
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
67
67
|
*/
|
|
68
|
+
/**
|
|
69
|
+
* Read and select the current route's loader data with type‑safety.
|
|
70
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDataHook
|
|
71
|
+
*/
|
|
68
72
|
export function useLoaderData<
|
|
69
73
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
70
74
|
const TFrom extends string | undefined = undefined,
|
package/src/useLoaderDeps.tsx
CHANGED
|
@@ -51,6 +51,10 @@ export type UseLoaderDepsRoute<out TId> = <
|
|
|
51
51
|
* @returns The loader deps (or selected value) for the matched route.
|
|
52
52
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
53
53
|
*/
|
|
54
|
+
/**
|
|
55
|
+
* Read and select the current route's loader dependencies object.
|
|
56
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLoaderDepsHook
|
|
57
|
+
*/
|
|
54
58
|
export function useLoaderDeps<
|
|
55
59
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
56
60
|
const TFrom extends string | undefined = undefined,
|
package/src/useLocation.tsx
CHANGED
|
@@ -37,6 +37,11 @@ export type UseLocationResult<
|
|
|
37
37
|
* @returns The current location (or selected value).
|
|
38
38
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
39
39
|
*/
|
|
40
|
+
/**
|
|
41
|
+
* Read the current location from the router state with optional selection.
|
|
42
|
+
* Useful for subscribing to just the pieces of location you care about.
|
|
43
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLocationHook
|
|
44
|
+
*/
|
|
40
45
|
export function useLocation<
|
|
41
46
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
42
47
|
TSelected = unknown,
|
package/src/useMatch.tsx
CHANGED
|
@@ -77,14 +77,6 @@ export type UseMatchResult<
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
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
80
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchHook
|
|
89
81
|
*/
|
|
90
82
|
export function useMatch<
|
package/src/useParams.tsx
CHANGED
|
@@ -73,6 +73,10 @@ export type UseParamsRoute<out TFrom> = <
|
|
|
73
73
|
* @returns The params object (or selected value) for the matched route.
|
|
74
74
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
|
|
75
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Access the current route's path parameters with type-safety.
|
|
78
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
|
|
79
|
+
*/
|
|
76
80
|
export function useParams<
|
|
77
81
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
78
82
|
const TFrom extends string | undefined = undefined,
|
package/src/useRouter.tsx
CHANGED
|
@@ -13,6 +13,11 @@ import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
|
|
|
13
13
|
* @returns The registered router instance.
|
|
14
14
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Access the current TanStack Router instance from React context.
|
|
18
|
+
* Must be used within a `RouterProvider`.
|
|
19
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
|
20
|
+
*/
|
|
16
21
|
export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
|
|
17
22
|
warn?: boolean
|
|
18
23
|
}): TRouter {
|
package/src/useRouterState.tsx
CHANGED
|
@@ -40,6 +40,11 @@ export type UseRouterStateResult<
|
|
|
40
40
|
* @returns The selected router state (or the full state by default).
|
|
41
41
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook
|
|
42
42
|
*/
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe to the router's state store with optional selection and
|
|
45
|
+
* structural sharing for render optimization.
|
|
46
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterStateHook
|
|
47
|
+
*/
|
|
43
48
|
export function useRouterState<
|
|
44
49
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
45
50
|
TSelected = unknown,
|
package/src/useSearch.tsx
CHANGED
|
@@ -73,6 +73,10 @@ export type UseSearchRoute<out TFrom> = <
|
|
|
73
73
|
* @returns The search object (or selected value) for the matched route.
|
|
74
74
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
|
|
75
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Read and select the current route's search parameters with type-safety.
|
|
78
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useSearchHook
|
|
79
|
+
*/
|
|
76
80
|
export function useSearch<
|
|
77
81
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
78
82
|
const TFrom extends string | undefined = undefined,
|