@tanstack/react-router 1.133.13 → 1.133.18
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/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +11 -0
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +28 -0
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +30 -0
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +11 -0
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +19 -0
- package/dist/esm/fileRoute.d.ts +11 -0
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/link.d.ts +28 -0
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/route.d.ts +30 -0
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +11 -0
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useNavigate.d.ts +19 -0
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/llms/rules/guide.d.ts +1 -1
- package/dist/llms/rules/guide.js +3 -0
- package/package.json +2 -2
- package/src/fileRoute.ts +11 -0
- package/src/link.tsx +28 -0
- package/src/route.tsx +30 -0
- package/src/router.ts +11 -0
- package/src/useNavigate.tsx +19 -0
package/dist/llms/rules/guide.js
CHANGED
|
@@ -5183,6 +5183,9 @@ const router = createRouter({
|
|
|
5183
5183
|
})
|
|
5184
5184
|
\`\`\`
|
|
5185
5185
|
|
|
5186
|
+
> [!TIP]
|
|
5187
|
+
> \`MyRouterContext\` only needs to contain content that will be passed directly to \`createRouter\` below. All other context added in \`beforeLoad\` will be inferred.
|
|
5188
|
+
|
|
5186
5189
|
## Passing the initial Router Context
|
|
5187
5190
|
|
|
5188
5191
|
The router context is passed to the router at instantiation time. You can pass the initial router context to the router via the \`context\` option:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.133.
|
|
3
|
+
"version": "1.133.18",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tiny-invariant": "^1.3.3",
|
|
81
81
|
"tiny-warning": "^1.0.3",
|
|
82
82
|
"@tanstack/history": "1.133.3",
|
|
83
|
-
"@tanstack/router-core": "1.133.
|
|
83
|
+
"@tanstack/router-core": "1.133.18"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@testing-library/jest-dom": "^6.6.3",
|
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
|
export function createFileRoute<
|
|
39
50
|
TFilePath extends keyof FileRoutesByPath,
|
|
40
51
|
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
package/src/link.tsx
CHANGED
|
@@ -514,6 +514,18 @@ export interface LinkComponentRoute<
|
|
|
514
514
|
): React.ReactElement
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Creates a typed Link-like component that preserves TanStack Router's
|
|
519
|
+
* navigation semantics and type-safety while delegating rendering to the
|
|
520
|
+
* provided host component.
|
|
521
|
+
*
|
|
522
|
+
* Useful for integrating design system anchors/buttons while keeping
|
|
523
|
+
* router-aware props (eg. `to`, `params`, `search`, `preload`).
|
|
524
|
+
*
|
|
525
|
+
* @param Comp The host component to render (eg. a design-system Link/Button)
|
|
526
|
+
* @returns A router-aware component with the same API as `Link`.
|
|
527
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-link
|
|
528
|
+
*/
|
|
517
529
|
export function createLink<const TComp>(
|
|
518
530
|
Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>,
|
|
519
531
|
): LinkComponent<TComp> {
|
|
@@ -522,6 +534,22 @@ export function createLink<const TComp>(
|
|
|
522
534
|
}) as any
|
|
523
535
|
}
|
|
524
536
|
|
|
537
|
+
/**
|
|
538
|
+
* A strongly-typed anchor component for declarative navigation.
|
|
539
|
+
* Handles path, search, hash and state updates with optional route preloading
|
|
540
|
+
* and active-state styling.
|
|
541
|
+
*
|
|
542
|
+
* Non-obvious props include:
|
|
543
|
+
* - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false)
|
|
544
|
+
* - `preloadDelay`: Delay in ms before preloading on hover
|
|
545
|
+
* - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive
|
|
546
|
+
* - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation
|
|
547
|
+
* - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation
|
|
548
|
+
* - `ignoreBlocker`: Bypass registered blockers
|
|
549
|
+
*
|
|
550
|
+
* @returns An anchor-like element that navigates without full page reloads.
|
|
551
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent
|
|
552
|
+
*/
|
|
525
553
|
export const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(
|
|
526
554
|
(props, ref) => {
|
|
527
555
|
const { _asChild, ...rest } = props
|
package/src/route.tsx
CHANGED
|
@@ -307,6 +307,17 @@ export class Route<
|
|
|
307
307
|
) as unknown as LinkComponentRoute<TFullPath>
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Creates a non-root Route instance for code-based routing.
|
|
312
|
+
*
|
|
313
|
+
* Use this to define a route that will be composed into a route tree
|
|
314
|
+
* (typically via a parent route's `addChildren`). If you're using file-based
|
|
315
|
+
* routing, prefer `createFileRoute`.
|
|
316
|
+
*
|
|
317
|
+
* @param options Route options (path, component, loader, context, etc.).
|
|
318
|
+
* @returns A Route instance to be attached to the route tree.
|
|
319
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction
|
|
320
|
+
*/
|
|
310
321
|
export function createRoute<
|
|
311
322
|
TRegister = unknown,
|
|
312
323
|
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
|
|
@@ -403,6 +414,15 @@ export type AnyRootRoute = RootRoute<
|
|
|
403
414
|
any
|
|
404
415
|
>
|
|
405
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Creates a root route factory that requires a router context type.
|
|
419
|
+
*
|
|
420
|
+
* Use when your root route expects `context` to be provided to `createRouter`.
|
|
421
|
+
* The returned function behaves like `createRootRoute` but enforces a context type.
|
|
422
|
+
*
|
|
423
|
+
* @returns A factory function to configure and return a root route.
|
|
424
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction
|
|
425
|
+
*/
|
|
406
426
|
export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
407
427
|
return <
|
|
408
428
|
TRegister = Register,
|
|
@@ -563,6 +583,16 @@ export class RootRoute<
|
|
|
563
583
|
) as unknown as LinkComponentRoute<'/'>
|
|
564
584
|
}
|
|
565
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Creates a root Route instance used to build your route tree.
|
|
588
|
+
*
|
|
589
|
+
* Typically paired with `createRouter({ routeTree })`. If you need to require
|
|
590
|
+
* a typed router context, use `createRootRouteWithContext` instead.
|
|
591
|
+
*
|
|
592
|
+
* @param options Root route options (component, error, pending, etc.).
|
|
593
|
+
* @returns A root route instance.
|
|
594
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction
|
|
595
|
+
*/
|
|
566
596
|
export function createRootRoute<
|
|
567
597
|
TRegister = Register,
|
|
568
598
|
TSearchValidator = undefined,
|
package/src/router.ts
CHANGED
|
@@ -77,6 +77,17 @@ declare module '@tanstack/router-core' {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Creates a new Router instance for React.
|
|
82
|
+
*
|
|
83
|
+
* Pass the returned router to `RouterProvider` to enable routing.
|
|
84
|
+
* Notable options: `routeTree` (your route definitions) and `context`
|
|
85
|
+
* (required if the root route was created with `createRootRouteWithContext`).
|
|
86
|
+
*
|
|
87
|
+
* @param options Router options used to configure the router.
|
|
88
|
+
* @returns A Router instance to be provided to `RouterProvider`.
|
|
89
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
|
90
|
+
*/
|
|
80
91
|
export const createRouter: CreateRouterFn = (options) => {
|
|
81
92
|
return new Router(options)
|
|
82
93
|
}
|
package/src/useNavigate.tsx
CHANGED
|
@@ -8,6 +8,16 @@ import type {
|
|
|
8
8
|
UseNavigateResult,
|
|
9
9
|
} from '@tanstack/router-core'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* React hook that returns a `navigate` function for programmatic navigation.
|
|
13
|
+
* Supports updating pathname, search, hash and state with full type-safety.
|
|
14
|
+
*
|
|
15
|
+
* Options:
|
|
16
|
+
* - `from`: Default base path used to resolve relative `to` destinations.
|
|
17
|
+
*
|
|
18
|
+
* @returns A memoized `navigate` function.
|
|
19
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook
|
|
20
|
+
*/
|
|
11
21
|
export function useNavigate<
|
|
12
22
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
13
23
|
TDefaultFrom extends string = string,
|
|
@@ -27,6 +37,15 @@ export function useNavigate<
|
|
|
27
37
|
) as UseNavigateResult<TDefaultFrom>
|
|
28
38
|
}
|
|
29
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Component that triggers a navigation when rendered. Navigation executes
|
|
42
|
+
* in an effect after mount/update.
|
|
43
|
+
*
|
|
44
|
+
* Props are the same as `NavigateOptions` used by `navigate()`.
|
|
45
|
+
*
|
|
46
|
+
* @returns null
|
|
47
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/navigateComponent
|
|
48
|
+
*/
|
|
30
49
|
export function Navigate<
|
|
31
50
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
32
51
|
const TFrom extends string = string,
|