@tanstack/react-router 1.33.2 → 1.33.3

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.
@@ -39,34 +39,184 @@ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext exten
39
39
  };
40
40
  export type TrailingSlashOption = 'always' | 'never' | 'preserve';
41
41
  export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDehydrated extends Record<string, any> = Record<string, any>, TSerializedError extends Record<string, any> = Record<string, any>> {
42
+ /**
43
+ * The history object that will be used to manage the browser history.
44
+ * If not provided, a new createBrowserHistory instance will be created and used.
45
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
46
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
47
+ */
42
48
  history?: RouterHistory;
49
+ /**
50
+ * A function that will be used to stringify search params when generating links.
51
+ * Defaults to `defaultStringifySearch`.
52
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
53
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
54
+ */
43
55
  stringifySearch?: SearchSerializer;
56
+ /**
57
+ * A function that will be used to parse search params when parsing the current location.
58
+ * Defaults to `defaultParseSearch`.
59
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
60
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
61
+ */
44
62
  parseSearch?: SearchParser;
63
+ /**
64
+ * Defaults to `false`
65
+ * If `false`, routes will not be preloaded by default in any way.
66
+ * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
67
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
68
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
69
+ */
45
70
  defaultPreload?: false | 'intent';
71
+ /**
72
+ * Defaults to 50
73
+ * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
74
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
75
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
76
+ */
46
77
  defaultPreloadDelay?: number;
78
+ /**
79
+ * Defaults to `Outlet`
80
+ * The default `component` a route should use if no component is provided.
81
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
82
+ */
47
83
  defaultComponent?: RouteComponent;
84
+ /**
85
+ * Defaults to `ErrorComponent`
86
+ * The default `errorComponent` a route should use if no error component is provided.
87
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
88
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
89
+ */
48
90
  defaultErrorComponent?: ErrorRouteComponent;
91
+ /**
92
+ * The default `pendingComponent` a route should use if no pending component is provided.
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
+ */
49
96
  defaultPendingComponent?: RouteComponent;
97
+ /**
98
+ * Defaults to `1000`
99
+ * The default `pendingMs` a route should use if no pendingMs is provided.
100
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
101
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
102
+ */
50
103
  defaultPendingMs?: number;
104
+ /**
105
+ * Defaults to `500`
106
+ * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
107
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
108
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
109
+ */
51
110
  defaultPendingMinMs?: number;
111
+ /**
112
+ * Defaults to `0`
113
+ * The default `staleTime` a route should use if no staleTime is
114
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
115
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
116
+ */
52
117
  defaultStaleTime?: number;
118
+ /**
119
+ * Defaults to `30_000` ms (30 seconds)
120
+ * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
121
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
122
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
123
+ */
53
124
  defaultPreloadStaleTime?: number;
125
+ /**
126
+ * Defaults to `routerOptions.defaultGcTime`, which defaults to 30 minutes.
127
+ * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
128
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
129
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
130
+ */
54
131
  defaultPreloadGcTime?: number;
132
+ /**
133
+ * The default `onCatch` handler for errors caught by the Router ErrorBoundary
134
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
135
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
136
+ */
55
137
  defaultOnCatch?: (error: Error, errorInfo: ErrorInfo) => void;
56
138
  defaultViewTransition?: boolean;
139
+ /**
140
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
141
+ */
57
142
  notFoundMode?: 'root' | 'fuzzy';
143
+ /**
144
+ * Defaults to 30 minutes.
145
+ * The default `gcTime` a route should use if no
146
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
147
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
148
+ */
58
149
  defaultGcTime?: number;
150
+ /**
151
+ * Defaults to `false`
152
+ * If `true`, all routes will be matched as case-sensitive.
153
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
154
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees#case-sensitivity)
155
+ */
59
156
  caseSensitive?: boolean;
157
+ /**
158
+ * Required
159
+ * The route tree that will be used to configure the router instance.
160
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
161
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees)
162
+ */
60
163
  routeTree?: TRouteTree;
164
+ /**
165
+ * Defaults to `/`
166
+ * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
167
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
168
+ */
61
169
  basepath?: string;
170
+ /**
171
+ * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
172
+ * The root context that will be provided to all routes in the route tree.
173
+ * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
174
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
175
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
176
+ */
62
177
  context?: TRouteTree['types']['routerContext'];
178
+ /**
179
+ * A function that will be called when the router is dehydrated.
180
+ * The return value of this function will be serialized and stored in the router's dehydrated state.
181
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
182
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
183
+ */
63
184
  dehydrate?: () => TDehydrated;
185
+ /**
186
+ * A function that will be called when the router is hydrated.
187
+ * The return value of this function will be serialized and stored in the router's dehydrated state.
188
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
189
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
190
+ */
64
191
  hydrate?: (dehydrated: TDehydrated) => void;
192
+ /**
193
+ * An array of route masks that will be used to mask routes in the route tree.
194
+ * 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.
195
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
196
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
197
+ */
65
198
  routeMasks?: Array<RouteMask<TRouteTree>>;
199
+ /**
200
+ * Defaults to `false`
201
+ * If `true`, route masks will, by default, be removed when the page is reloaded.
202
+ * 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.
203
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
204
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
205
+ */
66
206
  unmaskOnReload?: boolean;
207
+ /**
208
+ * A component that will be used to wrap the entire router.
209
+ * This is useful for providing a context to the entire router.
210
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
211
+ */
67
212
  Wrap?: (props: {
68
213
  children: any;
69
214
  }) => React.JSX.Element;
215
+ /**
216
+ * A component that will be used to wrap the inner contents of the router.
217
+ * 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.
218
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
219
+ */
70
220
  InnerWrap?: (props: {
71
221
  children: any;
72
222
  }) => React.JSX.Element;
@@ -74,11 +224,33 @@ export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption
74
224
  * @deprecated
75
225
  * Use `notFoundComponent` instead.
76
226
  * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
227
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
77
228
  */
78
229
  notFoundRoute?: AnyRoute;
230
+ /**
231
+ * Defaults to `NotFound`
232
+ * The default `notFoundComponent` a route should use if no notFound component is provided.
233
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
234
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
235
+ */
79
236
  defaultNotFoundComponent?: NotFoundRouteComponent;
237
+ /**
238
+ * The transformer that will be used when sending data between the server and the client during SSR.
239
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#transformer-property)
240
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/ssr#data-transformers)
241
+ */
80
242
  transformer?: RouterTransformer;
243
+ /**
244
+ * The serializer object that will be used to determine how errors are serialized and deserialized between the server and the client.
245
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#errorserializer-property)
246
+ */
81
247
  errorSerializer?: RouterErrorSerializer<TSerializedError>;
248
+ /**
249
+ * Defaults to `never`
250
+ * Configures how trailing slashes are treated.
251
+ * `'always'` will add a trailing slash if not present, `'never'` will remove the trailing slash if present and `'preserve'` will not modify the trailing slash.
252
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
253
+ */
82
254
  trailingSlash?: TTrailingSlashOption;
83
255
  }
84
256
  export interface RouterTransformer {