Skip to content

Commit 8ba812c

Browse files
MichaelDeBoeyjoseph0926
authored andcommitted
docs(api/other-api): add some extra reference links (#14171)
1 parent cf035f6 commit 8ba812c

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

docs/api/other-api/adapter.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ If you initialized your app with `npx create-react-router@latest` with something
1818

1919
<docs-info>If you're using the built-in React Router App Server, you don't interact with this API</docs-info>
2020

21-
Each adapter has the same API. In the future we may have helpers specific to the platform you're deploying to.
21+
Each adapter has the same API. In the future, we may have helpers specific to the platform you're deploying to.
2222

2323
## `@react-router/express`
2424

2525
[Reference Documentation ↗](https://api.reactrouter.com/v7/modules/_react_router_express.html)
2626

27-
Here's an example with express:
27+
Here's an example with [Express][express]:
2828

2929
```ts lines=[1-3,11-22]
3030
const {
@@ -60,15 +60,15 @@ You can refer to the [Express template][express-template] as a reference, but he
6060

6161
**1. Update deps**
6262

63-
```sh
63+
```shellscript nonumber
6464
npm uninstall @react-router/serve
6565
npm install @react-router/express compression express morgan cross-env
6666
npm install --save-dev @types/express @types/express-serve-static-core @types/morgan
6767
```
6868

6969
**2. Add a server**
7070

71-
Create your React Router express server in `server/app.ts`:
71+
Create your React Router Express server in `server/app.ts`:
7272

7373
```ts filename=server/app.ts
7474
import "react-router";
@@ -162,6 +162,7 @@ While not a direct "adapter" like the above, this package contains utilities for
162162

163163
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.
164164

165+
[express]: https://expressjs.com
165166
[node-releases]: https://nodejs.org/en/about/previous-releases
166167
[web-fetch-api]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
167168
[rr-serve]: ./serve

docs/api/other-api/dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ HMR handles client-side code updates like when you change the components, markup
5151
Likewise, HDR handles server-side code updates.
5252

5353
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.
5555

5656
</docs-info>
5757

@@ -108,7 +108,7 @@ react-router routes --json
108108

109109
## `react-router typegen`
110110

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.
112112

113113
```shellscript nonumber
114114
react-router typegen

docs/api/other-api/serve.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PORT=4000 npx react-router-serve build/index.js
4040

4141
Depending on `process.env.NODE_ENV`, the server will boot in development or production mode.
4242

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].
4444

4545
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.
4646

@@ -53,7 +53,9 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
5353
// cleared and this will be required brand new
5454
const cache = new Map();
5555

56-
export async function loader({ params }) {
56+
export async function loader({
57+
params,
58+
}: Route.LoaderArgs) {
5759
if (cache.has(params.foo)) {
5860
return cache.get(params.foo);
5961
}
@@ -62,11 +64,10 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
6264
cache.set(params.foo, record);
6365
return record;
6466
}
65-
66-
If you need a workaround for preserving cache in development, you can set up a [singleton][singleton] in your server.
67-
6867
```
6968

69+
If you need a workaround for preserving cache in development, you can set up a singleton in your server.
70+
7071
- Any **module side effects** will remain in place! This may cause problems but should probably be avoided anyway.
7172

7273
```tsx lines=[1-4]
@@ -80,16 +81,19 @@ In development, `react-router-serve` will ensure the latest code is run by purgi
8081
}
8182
```
8283

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.
8485

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.
8687

87-
[rr-express]: ./adapter#createrequesthandler
88+
[rr-express]: ./adapter#react-routerexpress
8889
[express-listen]: https://expressjs.com/en/api.html#app.listen
90+
[rr-config]: ../framework-conventions/react-router.config.ts
8991
[rr-serve-code]: https://github.com/remix-run/react-router/blob/main/packages/react-router-serve/cli.ts
9092
[compression]: https://expressjs.com/en/resources/middleware/compression.html
9193
[express-static]: https://expressjs.com/en/4x/api.html#express.static
9294
[serve-static]: https://expressjs.com/en/resources/middleware/serve-static.html
9395
[morgan]: https://expressjs.com/en/resources/middleware/morgan.html
94-
[express]: https://expressjs.com/
96+
[express]: https://expressjs.com
9597
[migrate-to-express]: ./adapter#migrating-from-the-react-router-app-server
98+
[pm2-dev]: https://npm.im/pm2-dev
99+
[nodemon]: https://npm.im/nodemon

0 commit comments

Comments
 (0)