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
In 2021, the HTTP Archive launched the [Core Web Vitals Technology Report dashboard](https://discuss.httparchive.org/t/new-dashboard-the-core-web-vitals-technology-report/2178):
183
+
184
+
> By combining the powers of real-user experiences in the Chrome UX Report 26 (CrUX) dataset with web technology detections in HTTP Archive 30, we can get a glimpse into how architectural decisions like choices of CMS platform or JavaScript framework play a role in sites’ CWV performance.
185
+
186
+
They use a tool called [`wappalyzer`](https://github.com/HTTPArchive/wappalyzer) to identify what technologies a given website is using by looking for certain scripts, global JS variables, or other identifying characteristics. For example, for Remix applications, they [look for the global `__remixContext`](https://github.com/HTTPArchive/wappalyzer/blob/c2a24ee7c2d07bf9c521f02584ae2dcf603ac0b7/src/technologies/r.json#L1328) variable to identify that a website is using Remix.
187
+
188
+
It was brought to our attention that React Router was unable to be reliably identified because there are no identifying global aspects. They are currently [looking for external scripts with `react-router`](https://github.com/HTTPArchive/wappalyzer/blob/c2a24ee7c2d07bf9c521f02584ae2dcf603ac0b7/src/technologies/r.json#L637) in the name. This will identify sites using React Router from a CDN such as `unpkg` - but it will miss the **vast** majority of sites that are installing React Router from the npm registry and bundling it into their JS files. This results in [drastically under-reporting](https://lookerstudio.google.com/s/pixHkNmGbN4) the usage of React Router on the web.
189
+
190
+
Starting with version `6.22.0`, sites using `react-router-dom` will begin adding a `window.__reactRouterVersion` variable that will be set to a string value of the SemVer major version number (i.e., `window.__reactRouterVersion = "6";`) so that they can be properly identified.
191
+
192
+
### Minor Changes
193
+
194
+
- Include a `window.__reactRouterVersion` for CWV Report detection ([#11222](https://github.com/remix-run/react-router/pull/11222))
195
+
- Add a `createStaticHandler``future.v7_throwAbortReason` flag to throw `request.signal.reason` (defaults to a `DOMException`) when a request is aborted instead of an `Error` such as `new Error("query() call aborted: GET /path")` ([#11104](https://github.com/remix-run/react-router/pull/11104))
196
+
- Please note that `DOMException` was added in Node v17 so you will not get a `DOMException` on Node 16 and below.
197
+
198
+
### Patch Changes
199
+
200
+
- Respect the `ErrorResponse` status code if passed to `getStaticContextFormError` ([#11213](https://github.com/remix-run/react-router/pull/11213))
Copy file name to clipboardExpand all lines: docs/routers/create-static-handler.md
+23-4Lines changed: 23 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,12 +54,27 @@ export async function renderHtml(req) {
54
54
55
55
```ts
56
56
declarefunction createStaticHandler(
57
-
routes:RouteObject[],
58
-
opts?: {
59
-
basename?:string;
60
-
}
57
+
routes:AgnosticRouteObject[],
58
+
opts?:CreateStaticHandlerOptions
61
59
):StaticHandler;
62
60
61
+
interfaceCreateStaticHandlerOptions {
62
+
basename?:string;
63
+
future?:Partial<StaticHandlerFutureConfig>;
64
+
mapRouteProperties?:MapRoutePropertiesFunction;
65
+
}
66
+
67
+
interfaceStaticHandlerFutureConfig {
68
+
v7_relativeSplatPath:boolean;
69
+
v7_throwAbortReason:boolean;
70
+
}
71
+
72
+
interfaceMapRoutePropertiesFunction {
73
+
(route:AgnosticRouteObject): {
74
+
hasErrorBoundary:boolean;
75
+
} &Record<string, any>;
76
+
}
77
+
63
78
interfaceStaticHandler {
64
79
dataRoutes:AgnosticDataRouteObject[];
65
80
query(
@@ -86,6 +101,8 @@ These are the same `routes`/`basename` you would pass to [`createBrowserRouter`]
86
101
87
102
The `handler.query()` method takes in a Fetch request, performs route matching, and executes all relevant route action/loader methods depending on the request. The return `context` value contains all of the information required to render the HTML document for the request (route-level `actionData`, `loaderData`, `errors`, etc.). If any of the matched routes return or throw a redirect response, then `query()` will return that redirect in the form of Fetch `Response`.
88
103
104
+
If a request is aborted, `query` will throw an error such as `Error("query() call aborted: GET /path")`. If you want to throw the native `AbortSignal.reason` (by default a `DOMException`) you can opt-in into the `future.v7_throwAbortReason` future flag. `DOMException` was added in Node 17 so you must be on Node 17 or higher for this to work properly.
105
+
89
106
### `opts.requestContext`
90
107
91
108
If you need to pass information from your server into Remix actions/loaders, you can do so with `opts.requestContext` and it will show up in your actions/loaders in the context parameter.
@@ -115,6 +132,8 @@ export async function render(req: express.Request) {
115
132
116
133
The `handler.queryRoute` is a more-targeted version that queries a singular route and runs it's loader or action based on the request. By default, it will match the target route based on the request URL. The return value is the values returned from the loader or action, which is usually a `Response` object.
117
134
135
+
If a request is aborted, `query` will throw an error such as `Error("queryRoute() call aborted: GET /path")`. If you want to throw the native `AbortSignal.reason` (by default a `DOMException`) you can opt-in into the `future.v7_throwAbortReason` future flag. `DOMException` was added in Node 17 so you must be on Node 17 or higher for this to work properly.
136
+
118
137
### `opts.routeId`
119
138
120
139
If you need to call a specific route action/loader that doesn't exactly correspond to the URL (for example, a parent route loader), you can specify a `routeId`:
0 commit comments