@tanstack/solid-router 1.112.11 → 1.112.15

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 (187) hide show
  1. package/dist/cjs/Match.cjs.map +1 -1
  2. package/dist/cjs/Matches.cjs.map +1 -1
  3. package/dist/cjs/Matches.d.cts +1 -8
  4. package/dist/cjs/RouterProvider.cjs.map +1 -1
  5. package/dist/cjs/RouterProvider.d.cts +4 -4
  6. package/dist/cjs/Transitioner.cjs +1 -1
  7. package/dist/cjs/Transitioner.cjs.map +1 -1
  8. package/dist/cjs/fileRoute.cjs.map +1 -1
  9. package/dist/cjs/fileRoute.d.cts +4 -7
  10. package/dist/cjs/index.d.cts +3 -5
  11. package/dist/cjs/link.cjs.map +1 -1
  12. package/dist/cjs/link.d.cts +1 -2
  13. package/dist/cjs/not-found.cjs.map +1 -1
  14. package/dist/cjs/not-found.d.cts +1 -2
  15. package/dist/cjs/redirects.cjs.map +1 -1
  16. package/dist/cjs/redirects.d.cts +1 -2
  17. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  18. package/dist/cjs/renderRouteNotFound.d.cts +1 -2
  19. package/dist/cjs/route.cjs +15 -23
  20. package/dist/cjs/route.cjs.map +1 -1
  21. package/dist/cjs/route.d.cts +19 -50
  22. package/dist/cjs/router.cjs +18 -20
  23. package/dist/cjs/router.cjs.map +1 -1
  24. package/dist/cjs/router.d.cts +84 -454
  25. package/dist/cjs/routerContext.cjs.map +1 -1
  26. package/dist/cjs/routerContext.d.cts +2 -2
  27. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  28. package/dist/cjs/scroll-restoration.d.cts +1 -2
  29. package/dist/cjs/typePrimitives.d.cts +1 -2
  30. package/dist/cjs/useBlocker.cjs.map +1 -1
  31. package/dist/cjs/useBlocker.d.cts +2 -3
  32. package/dist/cjs/useLoaderData.cjs.map +1 -1
  33. package/dist/cjs/useLoaderData.d.cts +1 -3
  34. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  35. package/dist/cjs/useLoaderDeps.d.cts +1 -3
  36. package/dist/cjs/useLocation.cjs.map +1 -1
  37. package/dist/cjs/useLocation.d.cts +1 -1
  38. package/dist/cjs/useMatch.cjs.map +1 -1
  39. package/dist/cjs/useMatch.d.cts +1 -3
  40. package/dist/cjs/useNavigate.cjs +1 -0
  41. package/dist/cjs/useNavigate.cjs.map +1 -1
  42. package/dist/cjs/useNavigate.d.cts +1 -2
  43. package/dist/cjs/useParams.cjs.map +1 -1
  44. package/dist/cjs/useParams.d.cts +1 -3
  45. package/dist/cjs/useRouteContext.cjs.map +1 -1
  46. package/dist/cjs/useRouteContext.d.cts +1 -2
  47. package/dist/cjs/useRouter.cjs.map +1 -1
  48. package/dist/cjs/useRouter.d.cts +1 -1
  49. package/dist/cjs/useRouterState.cjs.map +1 -1
  50. package/dist/cjs/useRouterState.d.cts +1 -1
  51. package/dist/cjs/useSearch.cjs.map +1 -1
  52. package/dist/cjs/useSearch.d.cts +1 -3
  53. package/dist/cjs/utils.cjs.map +1 -1
  54. package/dist/cjs/utils.d.cts +0 -9
  55. package/dist/esm/Match.js.map +1 -1
  56. package/dist/esm/Matches.d.ts +1 -8
  57. package/dist/esm/Matches.js.map +1 -1
  58. package/dist/esm/RouterProvider.d.ts +4 -4
  59. package/dist/esm/RouterProvider.js.map +1 -1
  60. package/dist/esm/Transitioner.js +1 -1
  61. package/dist/esm/Transitioner.js.map +1 -1
  62. package/dist/esm/fileRoute.d.ts +4 -7
  63. package/dist/esm/fileRoute.js.map +1 -1
  64. package/dist/esm/index.d.ts +3 -5
  65. package/dist/esm/link.d.ts +1 -2
  66. package/dist/esm/link.js.map +1 -1
  67. package/dist/esm/not-found.d.ts +1 -2
  68. package/dist/esm/not-found.js.map +1 -1
  69. package/dist/esm/redirects.d.ts +1 -2
  70. package/dist/esm/redirects.js.map +1 -1
  71. package/dist/esm/renderRouteNotFound.d.ts +1 -2
  72. package/dist/esm/renderRouteNotFound.js.map +1 -1
  73. package/dist/esm/route.d.ts +19 -50
  74. package/dist/esm/route.js +15 -23
  75. package/dist/esm/route.js.map +1 -1
  76. package/dist/esm/router.d.ts +84 -454
  77. package/dist/esm/router.js +18 -20
  78. package/dist/esm/router.js.map +1 -1
  79. package/dist/esm/routerContext.d.ts +2 -2
  80. package/dist/esm/routerContext.js.map +1 -1
  81. package/dist/esm/scroll-restoration.d.ts +1 -2
  82. package/dist/esm/scroll-restoration.js.map +1 -1
  83. package/dist/esm/typePrimitives.d.ts +1 -2
  84. package/dist/esm/useBlocker.d.ts +2 -3
  85. package/dist/esm/useBlocker.js.map +1 -1
  86. package/dist/esm/useLoaderData.d.ts +1 -3
  87. package/dist/esm/useLoaderData.js.map +1 -1
  88. package/dist/esm/useLoaderDeps.d.ts +1 -3
  89. package/dist/esm/useLoaderDeps.js.map +1 -1
  90. package/dist/esm/useLocation.d.ts +1 -1
  91. package/dist/esm/useLocation.js.map +1 -1
  92. package/dist/esm/useMatch.d.ts +1 -3
  93. package/dist/esm/useMatch.js.map +1 -1
  94. package/dist/esm/useNavigate.d.ts +1 -2
  95. package/dist/esm/useNavigate.js +1 -0
  96. package/dist/esm/useNavigate.js.map +1 -1
  97. package/dist/esm/useParams.d.ts +1 -3
  98. package/dist/esm/useParams.js.map +1 -1
  99. package/dist/esm/useRouteContext.d.ts +1 -2
  100. package/dist/esm/useRouteContext.js.map +1 -1
  101. package/dist/esm/useRouter.d.ts +1 -1
  102. package/dist/esm/useRouter.js.map +1 -1
  103. package/dist/esm/useRouterState.d.ts +1 -1
  104. package/dist/esm/useRouterState.js.map +1 -1
  105. package/dist/esm/useSearch.d.ts +1 -3
  106. package/dist/esm/useSearch.js.map +1 -1
  107. package/dist/esm/utils.d.ts +0 -9
  108. package/dist/esm/utils.js.map +1 -1
  109. package/dist/source/Matches.d.ts +1 -8
  110. package/dist/source/Matches.jsx.map +1 -1
  111. package/dist/source/RouterProvider.d.ts +4 -4
  112. package/dist/source/RouterProvider.jsx.map +1 -1
  113. package/dist/source/Transitioner.jsx +1 -1
  114. package/dist/source/Transitioner.jsx.map +1 -1
  115. package/dist/source/fileRoute.d.ts +4 -7
  116. package/dist/source/fileRoute.js.map +1 -1
  117. package/dist/source/index.d.ts +3 -5
  118. package/dist/source/index.jsx.map +1 -1
  119. package/dist/source/link.d.ts +1 -2
  120. package/dist/source/link.jsx.map +1 -1
  121. package/dist/source/not-found.d.ts +1 -2
  122. package/dist/source/not-found.jsx.map +1 -1
  123. package/dist/source/redirects.d.ts +1 -2
  124. package/dist/source/renderRouteNotFound.d.ts +1 -2
  125. package/dist/source/renderRouteNotFound.jsx.map +1 -1
  126. package/dist/source/route.d.ts +19 -50
  127. package/dist/source/route.js +15 -23
  128. package/dist/source/route.js.map +1 -1
  129. package/dist/source/router.d.ts +83 -454
  130. package/dist/source/router.js +23 -14
  131. package/dist/source/router.js.map +1 -1
  132. package/dist/source/routerContext.d.ts +2 -2
  133. package/dist/source/routerContext.jsx.map +1 -1
  134. package/dist/source/scroll-restoration.d.ts +1 -2
  135. package/dist/source/scroll-restoration.jsx.map +1 -1
  136. package/dist/source/typePrimitives.d.ts +1 -2
  137. package/dist/source/useBlocker.d.ts +2 -3
  138. package/dist/source/useBlocker.jsx.map +1 -1
  139. package/dist/source/useLoaderData.d.ts +1 -3
  140. package/dist/source/useLoaderData.jsx.map +1 -1
  141. package/dist/source/useLoaderDeps.d.ts +1 -3
  142. package/dist/source/useLoaderDeps.jsx.map +1 -1
  143. package/dist/source/useLocation.d.ts +1 -1
  144. package/dist/source/useLocation.jsx.map +1 -1
  145. package/dist/source/useMatch.d.ts +1 -3
  146. package/dist/source/useMatch.jsx.map +1 -1
  147. package/dist/source/useNavigate.d.ts +1 -2
  148. package/dist/source/useNavigate.jsx +1 -15
  149. package/dist/source/useNavigate.jsx.map +1 -1
  150. package/dist/source/useParams.d.ts +1 -3
  151. package/dist/source/useParams.jsx.map +1 -1
  152. package/dist/source/useRouteContext.d.ts +1 -2
  153. package/dist/source/useRouter.d.ts +1 -1
  154. package/dist/source/useRouterState.d.ts +1 -1
  155. package/dist/source/useRouterState.jsx.map +1 -1
  156. package/dist/source/useSearch.d.ts +1 -3
  157. package/dist/source/useSearch.jsx.map +1 -1
  158. package/dist/source/utils.d.ts +1 -10
  159. package/dist/source/utils.js.map +1 -1
  160. package/package.json +3 -3
  161. package/src/Match.tsx +1 -1
  162. package/src/Matches.tsx +4 -8
  163. package/src/RouterProvider.tsx +4 -7
  164. package/src/Transitioner.tsx +1 -1
  165. package/src/fileRoute.ts +9 -25
  166. package/src/index.tsx +22 -28
  167. package/src/link.tsx +2 -1
  168. package/src/not-found.tsx +1 -2
  169. package/src/redirects.ts +1 -1
  170. package/src/renderRouteNotFound.tsx +1 -2
  171. package/src/route.ts +93 -222
  172. package/src/router.ts +146 -591
  173. package/src/routerContext.tsx +3 -3
  174. package/src/scroll-restoration.tsx +6 -2
  175. package/src/typePrimitives.ts +2 -1
  176. package/src/useBlocker.tsx +7 -3
  177. package/src/useLoaderData.tsx +3 -2
  178. package/src/useLoaderDeps.tsx +3 -2
  179. package/src/useLocation.tsx +5 -1
  180. package/src/useMatch.tsx +3 -2
  181. package/src/useNavigate.tsx +3 -17
  182. package/src/useParams.tsx +3 -2
  183. package/src/useRouteContext.ts +2 -2
  184. package/src/useRouter.tsx +1 -1
  185. package/src/useRouterState.tsx +5 -1
  186. package/src/useSearch.tsx +3 -2
  187. package/src/utils.ts +0 -16
@@ -1,435 +1,77 @@
1
1
  import { Store } from '@tanstack/solid-store';
2
2
  import type * as Solid from 'solid-js';
3
- import type { HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';
4
- import type { NoInfer } from '@tanstack/solid-store';
5
- import type { AnyContext, AnyRedirect, AnyRouteMatch, AnySchema, BuildLocationFn, CommitLocationOptions, ControlledPromise, FullSearchSchema, MakeRemountDepsOptionsUnion, MakeRouteMatch, MakeRouteMatchUnion, Manifest, NavigateFn, NavigateOptions, NonNullableUpdater, ParsedLocation, PickAsRequired, Register, ResolveRelativePath, ResolvedRedirect, RouteById, RoutePaths, RoutesById, RoutesByPath, SearchParser, SearchSerializer, StartSerializer, ToOptions, TrailingSlashOption, Updater, ViewTransitionOptions } from '@tanstack/router-core';
6
- import type { AnyRoute, ErrorRouteComponent, NotFoundRouteComponent, RootRoute, RouteComponent, RouteMask } from './route';
7
- import type { MatchRouteOptions } from './Matches';
3
+ import type { RouterHistory } from '@tanstack/history';
4
+ import type { AnyRedirect, AnyRoute, AnyRouteMatch, AnyRouter, BuildLocationFn, BuildNextOptions, ClearCacheFn, CommitLocationFn, CommitLocationOptions, ControlledPromise, Router as CoreRouter, EmitFn, FullSearchSchema, GetMatchFn, GetMatchRoutesFn, InjectedHtmlEntry, InvalidateFn, LoadFn, MakeRouteMatch, Manifest, MatchRouteFn, MatchRoutesFn, NavigateFn, ParseLocationFn, ParsedLocation, PickAsRequired, PreloadRouteFn, ResolvedRedirect, RouterConstructorOptions, RouterEvent, RouterListener, RouterOptions, RouterState, RoutesById, RoutesByPath, StartSerializer, StartTransitionFn, SubscribeFn, TrailingSlashOption, UpdateFn, UpdateMatchFn, ViewTransitionOptions } from '@tanstack/router-core';
5
+ import type { ErrorRouteComponent, NotFoundRouteComponent, RouteComponent } from './route';
8
6
  import type { NotFoundError } from './not-found';
9
- declare global {
10
- interface Window {
11
- __TSR_ROUTER__?: AnyRouter;
12
- }
13
- }
14
- export type AnyRouter = Router<any, any, any, any, any>;
15
- export type RegisteredRouter = Register extends {
16
- router: infer TRouter extends AnyRouter;
17
- } ? TRouter : AnyRouter;
18
- export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree extends RootRoute<any, infer TRouterContext extends AnyContext, any, any, any, any, any, any> ? TRouterContext : AnyContext;
19
- export type ControllablePromise<T = any> = Promise<T> & {
20
- resolve: (value: T) => void;
21
- reject: (value?: any) => void;
22
- };
23
- export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
24
- context?: InferRouterContext<TRouteTree>;
25
- } : {
26
- context: InferRouterContext<TRouteTree>;
27
- };
28
- export type InjectedHtmlEntry = Promise<string>;
29
- export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>> {
30
- /**
31
- * The history object that will be used to manage the browser history.
32
- *
33
- * If not provided, a new createBrowserHistory instance will be created and used.
34
- *
35
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
36
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
37
- */
38
- history?: TRouterHistory;
39
- /**
40
- * A function that will be used to stringify search params when generating links.
41
- *
42
- * @default defaultStringifySearch
43
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
44
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
45
- */
46
- stringifySearch?: SearchSerializer;
47
- /**
48
- * A function that will be used to parse search params when parsing the current location.
49
- *
50
- * @default defaultParseSearch
51
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
52
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
53
- */
54
- parseSearch?: SearchParser;
55
- /**
56
- * If `false`, routes will not be preloaded by default in any way.
57
- *
58
- * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
59
- *
60
- * If `'viewport'`, routes will be preloaded by default when they are within the viewport.
61
- *
62
- * @default false
63
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
64
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
65
- */
66
- defaultPreload?: false | 'intent' | 'viewport' | 'render';
67
- /**
68
- * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
69
- *
70
- * @default 50
71
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
72
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
73
- */
74
- defaultPreloadDelay?: number;
75
- /**
76
- * The default `component` a route should use if no component is provided.
77
- *
78
- * @default Outlet
79
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
80
- */
81
- defaultComponent?: RouteComponent;
82
- /**
83
- * The default `errorComponent` a route should use if no error component is provided.
84
- *
85
- * @default ErrorComponent
86
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
87
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
88
- */
89
- defaultErrorComponent?: ErrorRouteComponent;
90
- /**
91
- * The default `pendingComponent` a route should use if no pending component is provided.
92
- *
93
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
94
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
95
- */
96
- defaultPendingComponent?: RouteComponent;
97
- /**
98
- * The default `pendingMs` a route should use if no pendingMs is provided.
99
- *
100
- * @default 1000
101
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
102
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
103
- */
104
- defaultPendingMs?: number;
105
- /**
106
- * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
107
- *
108
- * @default 500
109
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
110
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
111
- */
112
- defaultPendingMinMs?: number;
113
- /**
114
- * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.
115
- *
116
- * @default 0
117
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
118
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
119
- */
120
- defaultStaleTime?: number;
121
- /**
122
- * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
123
- *
124
- * @default 30_000 `(30 seconds)`
125
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
126
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
127
- */
128
- defaultPreloadStaleTime?: number;
129
- /**
130
- * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
131
- *
132
- * @default 1_800_000 `(30 minutes)`
133
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
134
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
135
- */
136
- defaultPreloadGcTime?: number;
137
- /**
138
- * The default `onCatch` handler for errors caught by the Router ErrorBoundary
139
- *
140
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
141
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
142
- */
143
- defaultOnCatch?: (error: Error) => void;
144
- /**
145
- * If `true`, route navigations will called using `document.startViewTransition()`.
146
- *
147
- * If the browser does not support this api, this option will be ignored.
148
- *
149
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
150
- *
151
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
152
- */
153
- defaultViewTransition?: boolean | ViewTransitionOptions;
154
- /**
155
- * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
156
- *
157
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
158
- *
159
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
160
- */
161
- defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions;
162
- /**
163
- * @default 'fuzzy'
164
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
165
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
166
- */
167
- notFoundMode?: 'root' | 'fuzzy';
168
- /**
169
- * The default `gcTime` a route should use if no gcTime is provided.
170
- *
171
- * @default 1_800_000 `(30 minutes)`
172
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
173
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
174
- */
175
- defaultGcTime?: number;
176
- /**
177
- * If `true`, all routes will be matched as case-sensitive.
178
- *
179
- * @default false
180
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
181
- */
182
- caseSensitive?: boolean;
183
- /**
184
- *
185
- * The route tree that will be used to configure the router instance.
186
- *
187
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
188
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
189
- */
190
- routeTree?: TRouteTree;
191
- /**
192
- * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
193
- *
194
- * @default '/'
195
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
196
- */
197
- basepath?: string;
198
- /**
199
- * The root context that will be provided to all routes in the route tree.
200
- *
201
- * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
202
- *
203
- * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
204
- *
205
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
206
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
207
- */
208
- context?: InferRouterContext<TRouteTree>;
209
- /**
210
- * A function that will be called when the router is dehydrated.
211
- *
212
- * The return value of this function will be serialized and stored in the router's dehydrated state.
213
- *
214
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
215
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
216
- */
217
- dehydrate?: () => TDehydrated;
218
- /**
219
- * A function that will be called when the router is hydrated.
220
- *
221
- * The return value of this function will be serialized and stored in the router's dehydrated state.
222
- *
223
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
224
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
225
- */
226
- hydrate?: (dehydrated: TDehydrated) => void;
227
- /**
228
- * An array of route masks that will be used to mask routes in the route tree.
229
- *
230
- * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.
231
- *
232
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
233
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
234
- */
235
- routeMasks?: Array<RouteMask<TRouteTree>>;
236
- /**
237
- * If `true`, route masks will, by default, be removed when the page is reloaded.
238
- *
239
- * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.
240
- *
241
- * @default false
242
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
243
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
244
- */
245
- unmaskOnReload?: boolean;
246
- /**
247
- * A component that will be used to wrap the entire router.
248
- *
249
- * This is useful for providing a context to the entire router.
250
- *
251
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
252
- *
253
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
254
- */
255
- Wrap?: (props: {
256
- children: any;
257
- }) => Solid.JSX.Element;
258
- /**
259
- * A component that will be used to wrap the inner contents of the router.
260
- *
261
- * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
262
- *
263
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
264
- *
265
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
266
- */
267
- InnerWrap?: (props: {
268
- children: any;
269
- }) => Solid.JSX.Element;
270
- /**
271
- * Use `notFoundComponent` instead.
272
- *
273
- * @deprecated
274
- * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
275
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
276
- */
277
- notFoundRoute?: AnyRoute;
278
- /**
279
- * The default `notFoundComponent` a route should use if no notFound component is provided.
280
- *
281
- * @default NotFound
282
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
283
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
284
- */
285
- defaultNotFoundComponent?: NotFoundRouteComponent;
286
- /**
287
- * Configures how trailing slashes are treated.
288
- *
289
- * - `'always'` will add a trailing slash if not present
290
- * - `'never'` will remove the trailing slash if present
291
- * - `'preserve'` will not modify the trailing slash.
292
- *
293
- * @default 'never'
294
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
295
- */
296
- trailingSlash?: TTrailingSlashOption;
297
- /**
298
- * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.
299
- *
300
- * @default typeof document !== 'undefined'
301
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
302
- */
303
- isServer?: boolean;
304
- defaultSsr?: boolean;
305
- search?: {
7
+ declare module '@tanstack/router-core' {
8
+ interface RouterOptionsExtensions {
306
9
  /**
307
- * Configures how unknown search params (= not returned by any `validateSearch`) are treated.
10
+ * A component that will be used to wrap the entire router.
308
11
  *
309
- * @default false
310
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
12
+ * This is useful for providing a context to the entire router.
13
+ *
14
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
15
+ *
16
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
311
17
  */
312
- strict?: boolean;
313
- };
314
- /**
315
- * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
316
- *
317
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
318
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
319
- */
320
- pathParamsAllowedCharacters?: Array<';' | ':' | '@' | '&' | '=' | '+' | '$' | ','>;
321
- defaultRemountDeps?: (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any;
322
- /**
323
- * If `true`, scroll restoration will be enabled
324
- *
325
- * @default false
326
- */
327
- scrollRestoration?: boolean;
328
- /**
329
- * A function that will be called to get the key for the scroll restoration cache.
330
- *
331
- * @default (location) => location.href
332
- */
333
- getScrollRestorationKey?: (location: ParsedLocation) => string;
334
- /**
335
- * The default behavior for scroll restoration.
336
- *
337
- * @default 'auto'
338
- */
339
- scrollRestorationBehavior?: ScrollBehavior;
340
- /**
341
- * An array of selectors that will be used to scroll to the top of the page in addition to `window`
342
- *
343
- * @default ['window']
344
- */
345
- scrollToTopSelectors?: Array<string>;
346
- }
347
- export interface RouterErrorSerializer<TSerializedError> {
348
- serialize: (err: unknown) => TSerializedError;
349
- deserialize: (err: TSerializedError) => unknown;
350
- }
351
- export interface RouterState<TRouteTree extends AnyRoute = AnyRoute, TRouteMatch = MakeRouteMatchUnion> {
352
- status: 'pending' | 'idle';
353
- loadedAt: number;
354
- isLoading: boolean;
355
- isTransitioning: boolean;
356
- matches: Array<TRouteMatch>;
357
- pendingMatches?: Array<TRouteMatch>;
358
- cachedMatches: Array<TRouteMatch>;
359
- location: ParsedLocation<FullSearchSchema<TRouteTree>>;
360
- resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>;
361
- statusCode: number;
362
- redirect?: ResolvedRedirect;
363
- }
364
- export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
365
- export interface BuildNextOptions {
366
- to?: string | number | null;
367
- params?: true | Updater<unknown>;
368
- search?: true | Updater<unknown>;
369
- hash?: true | Updater<string>;
370
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
371
- mask?: {
372
- to?: string | number | null;
373
- params?: true | Updater<unknown>;
374
- search?: true | Updater<unknown>;
375
- hash?: true | Updater<string>;
376
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
377
- unmaskOnReload?: boolean;
378
- };
379
- from?: string;
380
- _fromLocation?: ParsedLocation;
381
- href?: string;
382
- }
383
- export interface MatchedRoutesResult {
384
- matchedRoutes: Array<AnyRoute>;
385
- routeParams: Record<string, string>;
18
+ Wrap?: (props: {
19
+ children: any;
20
+ }) => Solid.JSX.Element;
21
+ /**
22
+ * A component that will be used to wrap the inner contents of the router.
23
+ *
24
+ * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
25
+ *
26
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
27
+ *
28
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
29
+ */
30
+ InnerWrap?: (props: {
31
+ children: any;
32
+ }) => Solid.JSX.Element;
33
+ /**
34
+ * The default `component` a route should use if no component is provided.
35
+ *
36
+ * @default Outlet
37
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
38
+ */
39
+ defaultComponent?: RouteComponent;
40
+ /**
41
+ * The default `errorComponent` a route should use if no error component is provided.
42
+ *
43
+ * @default ErrorComponent
44
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
45
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
46
+ */
47
+ defaultErrorComponent?: ErrorRouteComponent;
48
+ /**
49
+ * The default `pendingComponent` a route should use if no pending component is provided.
50
+ *
51
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
52
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
53
+ */
54
+ defaultPendingComponent?: RouteComponent;
55
+ /**
56
+ * The default `notFoundComponent` a route should use if no notFound component is provided.
57
+ *
58
+ * @default NotFound
59
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
60
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
61
+ */
62
+ defaultNotFoundComponent?: NotFoundRouteComponent;
63
+ /**
64
+ * The default `onCatch` handler for errors caught by the Router ErrorBoundary
65
+ *
66
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
67
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
68
+ */
69
+ defaultOnCatch?: (error: Error) => void;
70
+ }
386
71
  }
387
- export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
388
72
  export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent", "notFoundComponent"];
389
- type NavigationEventInfo = {
390
- fromLocation?: ParsedLocation;
391
- toLocation: ParsedLocation;
392
- pathChanged: boolean;
393
- hrefChanged: boolean;
394
- hashChanged: boolean;
395
- };
396
- export type RouterEvents = {
397
- onBeforeNavigate: {
398
- type: 'onBeforeNavigate';
399
- } & NavigationEventInfo;
400
- onBeforeLoad: {
401
- type: 'onBeforeLoad';
402
- } & NavigationEventInfo;
403
- onLoad: {
404
- type: 'onLoad';
405
- } & NavigationEventInfo;
406
- onResolved: {
407
- type: 'onResolved';
408
- } & NavigationEventInfo;
409
- onBeforeRouteMount: {
410
- type: 'onBeforeRouteMount';
411
- } & NavigationEventInfo;
412
- onInjectedHtml: {
413
- type: 'onInjectedHtml';
414
- promise: Promise<string>;
415
- };
416
- onRendered: {
417
- type: 'onRendered';
418
- } & NavigationEventInfo;
419
- };
420
- export type RouterEvent = RouterEvents[keyof RouterEvents];
421
- export type RouterListener<TRouterEvent extends RouterEvent> = {
422
- eventType: TRouterEvent['type'];
423
- fn: ListenerFn<TRouterEvent>;
424
- };
425
- export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>): Router<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated, TSerializedError>;
426
- type MatchRoutesOpts = {
427
- preload?: boolean;
428
- throwOnError?: boolean;
429
- _buildLocation?: boolean;
430
- dest?: BuildNextOptions;
431
- };
432
- export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>, in out TSerializedError extends Record<string, any> = Record<string, any>> {
73
+ export declare function createRouter<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>): CoreRouter<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>;
74
+ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> implements CoreRouter<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated> {
433
75
  tempLocationKey: string | undefined;
434
76
  resetNextScroll: boolean;
435
77
  shouldViewTransition?: boolean | ViewTransitionOptions;
@@ -439,7 +81,7 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
439
81
  isScrollRestoring: boolean;
440
82
  isScrollRestorationSetup: boolean;
441
83
  __store: Store<RouterState<TRouteTree>>;
442
- options: PickAsRequired<RouterOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
84
+ options: PickAsRequired<RouterOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
443
85
  history: TRouterHistory;
444
86
  latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
445
87
  basepath: string;
@@ -452,14 +94,14 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
452
94
  /**
453
95
  * @deprecated Use the `createRouter` function instead
454
96
  */
455
- constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>);
456
- startSolidTransition: (fn: () => void) => void;
457
- update: (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>) => void;
97
+ constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>);
98
+ startTransition: StartTransitionFn;
99
+ update: UpdateFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory, TDehydrated>;
458
100
  get state(): RouterState<TRouteTree, import("@tanstack/router-core").RouteMatch<any, any, any, any, any, any, any>>;
459
101
  buildRouteTree: () => void;
460
- subscribe: <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
461
- emit: (routerEvent: RouterEvent) => void;
462
- parseLocation: (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
102
+ subscribe: SubscribeFn;
103
+ emit: EmitFn;
104
+ parseLocation: ParseLocationFn<TRouteTree>;
463
105
  resolvePathWithBase: (from: string, path: string) => string;
464
106
  get looseRoutesById(): Record<string, AnyRoute>;
465
107
  /**
@@ -471,28 +113,21 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
471
113
  ): Array<AnyRouteMatch>;
472
114
  ```
473
115
  */
474
- matchRoutes(pathname: string, locationSearch: AnySchema, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
475
- matchRoutes(next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
116
+ matchRoutes: MatchRoutesFn;
476
117
  private matchRoutesInternal;
477
- getMatchedRoutes: (next: ParsedLocation, dest?: BuildNextOptions) => {
478
- matchedRoutes: AnyRoute[];
479
- routeParams: Record<string, string>;
480
- foundRoute: AnyRoute | undefined;
481
- };
118
+ getMatchedRoutes: GetMatchRoutesFn;
482
119
  cancelMatch: (id: string) => void;
483
120
  cancelMatches: () => void;
484
121
  buildLocation: BuildLocationFn;
485
122
  commitLocationPromise: undefined | ControlledPromise<void>;
486
- commitLocation: ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
123
+ commitLocation: CommitLocationFn;
487
124
  buildAndCommitLocation: ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, href, ...rest }?: BuildNextOptions & CommitLocationOptions) => Promise<void>;
488
125
  navigate: NavigateFn;
489
126
  latestLoadPromise: undefined | Promise<void>;
490
- load: (opts?: {
491
- sync?: boolean;
492
- }) => Promise<void>;
127
+ load: LoadFn;
493
128
  startViewTransition: (fn: () => Promise<void>) => void;
494
- updateMatch: (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
495
- getMatch: (matchId: string) => import("@tanstack/router-core").RouteMatch<any, any, any, any, any, any, any> | undefined;
129
+ updateMatch: UpdateMatchFn;
130
+ getMatch: GetMatchFn;
496
131
  loadMatches: ({ location, matches, preload: allPreload, onReady, updateMatch, sync, }: {
497
132
  location: ParsedLocation;
498
133
  matches: Array<AnyRouteMatch>;
@@ -502,18 +137,13 @@ export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailing
502
137
  getMatch?: (matchId: string) => AnyRouteMatch | undefined;
503
138
  sync?: boolean;
504
139
  }) => Promise<Array<MakeRouteMatch>>;
505
- invalidate: <TRouter extends AnyRouter = this>(opts?: {
506
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
507
- sync?: boolean;
508
- }) => Promise<void>;
140
+ invalidate: InvalidateFn<this>;
509
141
  resolveRedirect: (err: AnyRedirect) => ResolvedRedirect;
510
- clearCache: <TRouter extends AnyRouter = this>(opts?: {
511
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
512
- }) => void;
142
+ clearCache: ClearCacheFn<this>;
513
143
  clearExpiredCache: () => void;
514
144
  loadRouteChunk: (route: AnyRoute) => Promise<void[]>;
515
- preloadRoute: <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = "">(opts: NavigateOptions<Router<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
516
- matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<Router<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated, TSerializedError>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
145
+ preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory>;
146
+ matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, false, TRouterHistory>;
517
147
  ssr?: {
518
148
  manifest: Manifest | undefined;
519
149
  serializer: StartSerializer;
@@ -545,4 +175,3 @@ export declare class SearchParamError extends Error {
545
175
  export declare class PathParamError extends Error {
546
176
  }
547
177
  export declare function getInitialRouterState(location: ParsedLocation): RouterState<any>;
548
- export {};