@@ -23,6 +23,8 @@ Route modules are the foundation of React Router's framework features, they defi
23
23
24
24
This guide is a quick overview of every route module feature. The rest of the getting started guides will cover these features in more detail.
25
25
26
+ For additional details, please refer to the API documentation for a [ Route Module] [ route-module ]
27
+
26
28
## Component (` default ` )
27
29
28
30
Defines the component that will render when the route matches.
@@ -40,6 +42,10 @@ export default function MyRouteComponent() {
40
42
}
41
43
```
42
44
45
+ See also:
46
+
47
+ - [ ` default ` export Component props] [ component-props ]
48
+
43
49
## ` loader `
44
50
45
51
Route loaders provide data to route components before they are rendered. They are only called on the server when server rendering or during the build with pre-rendering.
@@ -130,6 +136,10 @@ export async function action({ request }) {
130
136
}
131
137
```
132
138
139
+ See also:
140
+
141
+ - [ ` action ` params] [ action-params ]
142
+
133
143
## ` clientAction `
134
144
135
145
Like route actions but only called in the browser.
@@ -157,9 +167,7 @@ import {
157
167
useRouteError ,
158
168
} from " react-router" ;
159
169
160
- export function ErrorBoundary() {
161
- const error = useRouteError ();
162
-
170
+ export function ErrorBoundary({ error }) {
163
171
if (isRouteErrorResponse (error )) {
164
172
return (
165
173
<div >
@@ -184,6 +192,12 @@ export function ErrorBoundary() {
184
192
}
185
193
```
186
194
195
+ See also:
196
+
197
+ - [ ` ErrorBoundary ` props] [ errorboundary-props ]
198
+ - [ ` isRouteErorResponse ` docs] [ is-route-error-response ]
199
+ - [ React Error Boundaries docs] [ error-boundaries ]
200
+
187
201
## ` HydrateFallback `
188
202
189
203
On initial page load, the route component renders only after the client loader is finished. If exported, a ` HydrateFallback ` can render immediately in place of the route component.
@@ -203,9 +217,13 @@ export default function Component({ loaderData }) {
203
217
}
204
218
```
205
219
220
+ See also:
221
+
222
+ - [ ` HydrateFallback ` props] [ hydratefallback-props ]
223
+
206
224
## ` headers `
207
225
208
- Route headers define HTTP headers to be sent with the response when server rendering.
226
+ Route headers define HTTP [ headers] to be sent with the response when server rendering.
209
227
210
228
``` tsx
211
229
export function headers() {
@@ -216,6 +234,11 @@ export function headers() {
216
234
}
217
235
```
218
236
237
+ See also:
238
+
239
+ - [ ` headers ` params] [ headers-params ]
240
+ - [ ` Cache-Control ` header] [ cache-control-header ]
241
+
219
242
## ` handle `
220
243
221
244
Route handle allows apps to add anything to a route match in ` useMatches ` to create abstractions (like breadcrumbs, etc.).
@@ -226,6 +249,11 @@ export const handle = {
226
249
};
227
250
```
228
251
252
+ See also:
253
+
254
+ - [ ` handle ` docs] [ handle ]
255
+ - [ ` useMatches ` docs] [ use-matches ]
256
+
229
257
## ` links `
230
258
231
259
Route links define [ ` <link> ` element] [ link-element ] s to be rendered in the document ` <head> ` .
@@ -269,9 +297,13 @@ export default function Root() {
269
297
}
270
298
```
271
299
300
+ See also:
301
+
302
+ - [ ` links ` params] [ links-params ]
303
+
272
304
## ` meta `
273
305
274
- Route meta defines meta tags to be rendered in the ` <head> ` of the document.
306
+ Route meta defines [ ` < meta> ` ] [ meta-element ] tags to be rendered in the ` <head> ` of the document.
275
307
276
308
``` tsx
277
309
export function meta() {
@@ -307,7 +339,7 @@ export default function Root() {
307
339
}
308
340
```
309
341
310
- ** See also**
342
+ See also:
311
343
312
344
- [ ` meta ` params] [ meta-params ]
313
345
@@ -325,22 +357,31 @@ export function shouldRevalidate(
325
357
}
326
358
```
327
359
360
+ See also:
361
+
362
+ - [ ` shouldRevalidate ` params] [ shouldrevalidate-params ]
363
+
328
364
---
329
365
330
366
Next: [ Rendering Strategies] ( ./rendering )
331
367
332
- [ fetch ] : https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
333
- [ loader-params ] : https://api.reactrouter.com/v7/interfaces/react_router.LoaderFunctionArgs
334
- [ client-loader-params ] : https://api.reactrouter.com/v7/types/react_router.ClientLoaderFunctionArgs
335
- [ action-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ActionFunctionArgs
336
- [ client-action-params ] : https://api.reactrouter.com/v7/types/react_router.ClientActionFunctionArgs
337
368
[ error-boundaries ] : https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
338
- [ use-route-error ] : https://api.reactrouter.com/v7/functions/react_router.useRouteError
339
369
[ is-route-error-response ] : https://api.reactrouter.com/v7/functions/react_router.isRouteErrorResponse
340
370
[ cache-control-header ] : https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
341
371
[ headers ] : https://developer.mozilla.org/en-US/docs/Web/API/Response
342
372
[ use-matches ] : https://api.reactrouter.com/v7/functions/react_router.useMatches
343
373
[ link-element ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
344
374
[ meta-element ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
345
- [ meta-params ] : https://api.reactrouter.com/v7/interfaces/react_router.MetaArgs
346
- [ use-revalidator ] : https://api.reactrouter.com/v7/functions/react_router.useRevalidator.html
375
+ [ route-module ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html
376
+ [ component-props ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#default
377
+ [ loader-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#loader
378
+ [ client-loader-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#clientLoader
379
+ [ action-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#actioin
380
+ [ client-action-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#clientAction
381
+ [ meta-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#meta
382
+ [ links-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#links
383
+ [ handle ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#handle
384
+ [ errorboundary-props ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#ErrorBoundary
385
+ [ hydratefallback-props ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#HydrateFallback
386
+ [ headers-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#headers
387
+ [ shouldrevalidate-params ] : https://api.reactrouter.com/v7/interfaces/react_router.ServerRouteModule.html#shouldRevalidate
0 commit comments