You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create your React Router express server in `server/app.ts`:
71
+
Create your React Router Express server in `server/app.ts`:
72
72
73
73
```ts filename=server/app.ts
74
74
import"react-router";
@@ -162,6 +162,7 @@ While not a direct "adapter" like the above, this package contains utilities for
162
162
163
163
React Router officially supports **Active** and **Maintenance**[Node LTS versions][node-releases] at any given point in time. Dropped support for End of Life Node versions is done in a React Router Minor release.
Copy file name to clipboardExpand all lines: docs/api/other-api/dev.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ HMR handles client-side code updates like when you change the components, markup
51
51
Likewise, HDR handles server-side code updates.
52
52
53
53
That means any time you make a change to the current page (or any code that your current page depends on), React Router will re-fetch data from your [loaders][loaders].
54
-
That way your app is _always_ up-to-date with the latest code changes, client-side or server-side.
54
+
That way your app is _always_ up to date with the latest code changes, client-side or server-side.
55
55
56
56
</docs-info>
57
57
@@ -108,7 +108,7 @@ react-router routes --json
108
108
109
109
## `react-router typegen`
110
110
111
-
Generates TypeScript types for your routes. This happens automatically during development, but you can manually run it when needed, e.g. to generate types in CI before running `tsc`. See [Type Safety][type-safety] for more information.
111
+
Generates TypeScript types for your routes. This happens automatically during development, but you can manually run it when needed, e.g., to generate types in CI before running `tsc`. See [Type Safety][type-safety] for more information.
Depending on `process.env.NODE_ENV`, the server will boot in development or production mode.
42
42
43
-
The `server-build-path` needs to point to the `serverBuildPath` defined in `react-router.config.ts`.
43
+
The `server-build-path` needs to point to the `serverBuildPath` defined in [`react-router.config.ts`][rr-config].
44
44
45
45
Because only the build artifacts (`build/`, `public/build/`) need to be deployed to production, the `react-router.config.ts` is not guaranteed to be available in production, so you need to tell React Router where your server build is with this option.
46
46
@@ -53,7 +53,9 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
53
53
// cleared and this will be required brand new
54
54
const cache =newMap();
55
55
56
-
exportasyncfunction loader({ params }) {
56
+
exportasyncfunction loader({
57
+
params,
58
+
}:Route.LoaderArgs) {
57
59
if (cache.has(params.foo)) {
58
60
returncache.get(params.foo);
59
61
}
@@ -62,11 +64,10 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
If you need a workaround for preserving cache in development, you can set up a singleton in your server.
70
+
70
71
- Any **module side effects** will remain in place! This may cause problems but should probably be avoided anyway.
71
72
72
73
```tsx lines=[1-4]
@@ -80,16 +81,19 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
80
81
}
81
82
```
82
83
83
-
If you need to write your code in a way that has these types of module side effects, you should set up your own [@react-router/express][rr-express] server and a tool in development like `pm2-dev` or `nodemon` to restart the server on file changes instead.
84
+
If you need to write your code in a way that has these types of module side effects, you should set up your own [@react-router/express][rr-express] server and a tool in development like [`pm2-dev`][pm2-dev] or [`nodemon`][nodemon] to restart the server on file changes instead.
84
85
85
-
In production this doesn't happen. The server boots up, and that's the end of it.
86
+
In production, this doesn't happen. The server boots up, and that's the end of it.
0 commit comments