Skip to content

Commit 68fd70b

Browse files
docs(router): update types for RouteOptions and RouteMatch (#4754)
Closes #3811 --------- Signed-off-by: leesb971204 <[email protected]> Co-authored-by: Sean Cassiere <[email protected]>
1 parent 5809382 commit 68fd70b

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

docs/router/framework/react/api/router/RouteMatchType.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ interface RouteMatch {
1111
routeId: string
1212
pathname: string
1313
params: Route['allParams']
14-
status: 'pending' | 'success' | 'error'
15-
isFetching: boolean
14+
status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'
15+
isFetching: false | 'beforeLoad' | 'loader'
1616
showPending: boolean
1717
error: unknown
1818
paramsError: unknown
@@ -25,5 +25,6 @@ interface RouteMatch {
2525
fetchedAt: number
2626
abortController: AbortController
2727
cause: 'enter' | 'stay'
28+
ssr?: boolean | 'data-only'
2829
}
2930
```

docs/router/framework/react/api/router/RouteOptionsType.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,69 @@ If you want to configure to remount a route component upon `params` change, use:
300300
```tsx
301301
remountDeps: ({ params }) => params
302302
```
303+
304+
### `headers` method
305+
306+
- Type:
307+
308+
```tsx
309+
type headers = (opts: {
310+
matches: Array<RouteMatch>
311+
match: RouteMatch
312+
params: TAllParams
313+
loaderData?: TLoaderData
314+
}) => Promise<Record<string, string>> | Record<string, string>
315+
```
316+
317+
- Optional
318+
- Allows you to specify custom HTTP headers to be sent when this route is rendered during SSR. The function receives the current match context and should return a plain object of header name/value pairs.
319+
320+
### `head` method
321+
322+
- Type:
323+
324+
```tsx
325+
type head = (ctx: {
326+
matches: Array<RouteMatch>
327+
match: RouteMatch
328+
params: TAllParams
329+
loaderData?: TLoaderData
330+
}) =>
331+
| Promise<{
332+
links?: RouteMatch['links']
333+
scripts?: RouteMatch['headScripts']
334+
meta?: RouteMatch['meta']
335+
styles?: RouteMatch['styles']
336+
}>
337+
| {
338+
links?: RouteMatch['links']
339+
scripts?: RouteMatch['headScripts']
340+
meta?: RouteMatch['meta']
341+
styles?: RouteMatch['styles']
342+
}
343+
```
344+
345+
- Optional
346+
- Returns additional elements to inject into the document `<head>` for this route. Use it to add route-level SEO metadata, preload links, inline styles, or custom scripts.
347+
348+
### `scripts` method
349+
350+
- Type:
351+
352+
```tsx
353+
type scripts = (ctx: {
354+
matches: Array<RouteMatch>
355+
match: RouteMatch
356+
params: TAllParams
357+
loaderData?: TLoaderData
358+
}) => Promise<RouteMatch['scripts']> | RouteMatch['scripts']
359+
```
360+
361+
- Optional
362+
- A shorthand helper to return only `<script>` elements. Equivalent to returning the `scripts` field from the `head` method.
363+
364+
### `codeSplitGroupings` property
365+
366+
- Type: `Array<Array<'loader' | 'component' | 'pendingComponent' | 'notFoundComponent' | 'errorComponent'>>`
367+
- Optional
368+
- Fine-grained control over how the router groups lazy-loaded pieces of a route into chunks. Each inner array represents a group of assets that will be placed into the same bundle during code-splitting.

docs/router/framework/react/guide/document-head-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export const Route = createRootRoute({
4343
children: `p {
4444
color: blue;
4545
background-color: yellow;
46-
}`
47-
}
48-
]
46+
}`,
47+
},
48+
],
4949
scripts: [
5050
{
5151
src: 'https://www.google-analytics.com/analytics.js',

0 commit comments

Comments
 (0)