|
1 | 1 | # `@react-router/dev` |
2 | 2 |
|
| 3 | +## 7.13.2-pre.0 |
| 4 | + |
| 5 | +### Patch Changes |
| 6 | + |
| 7 | +- Fix `react-router dev` crash when Unix socket files exist in the project root ([#14854](https://github.com/remix-run/react-router/pull/14854)) |
| 8 | +- Escape redirect locations in prerendered redirect HTML ([#14880](https://github.com/remix-run/react-router/pull/14880)) |
| 9 | +- Add `future.unstable_passThroughRequests` flag ([#14775](https://github.com/remix-run/react-router/pull/14775)) |
| 10 | + |
| 11 | + By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details (`.data` suffixes, `index` + `_routes` query params). |
| 12 | + |
| 13 | + Enabling this flag removes that normalization and passes the raw HTTP `request` instance to your handlers. This provides a few benefits: |
| 14 | + - Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path |
| 15 | + - Allows you to distinguish document from data requests in your handlers base don the presence of a `.data` suffix (useful for observability purposes) |
| 16 | + |
| 17 | + If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `unstable_url` parameter which contains a `URL` instance representing the normalized location: |
| 18 | + |
| 19 | + ```tsx |
| 20 | + // ❌ Before: you could assume there was no `.data` suffix in `request.url` |
| 21 | + export async function loader({ request }: Route.LoaderArgs) { |
| 22 | + let url = new URL(request.url); |
| 23 | + if (url.pathname === "/path") { |
| 24 | + // This check will fail with the flag enabled because the `.data` suffix will |
| 25 | + // exist on data requests |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + // ✅ After: use `unstable_url` for normalized routing logic and `request.url` |
| 30 | + // for raw routing logic |
| 31 | + export async function loader({ request, unstable_url }: Route.LoaderArgs) { |
| 32 | + if (unstable_url.pathname === "/path") { |
| 33 | + // This will always have the `.data` suffix stripped |
| 34 | + } |
| 35 | + |
| 36 | + // And now you can distinguish between document versus data requests |
| 37 | + let isDataRequest = new URL(request.url).pathname.endsWith(".data"); |
| 38 | + } |
| 39 | + ``` |
| 40 | + |
| 41 | +- Add a new `unstable_url: URL` parameter to route handler methods (`loader`, `action`, `middleware`, etc.) representing the normalized URL the application is navigating to or fetching, with React Router implementation details removed (`.data`suffix, `index`/`_routes` query params) ([#14775](https://github.com/remix-run/react-router/pull/14775)) |
| 42 | + |
| 43 | + This is being added alongside the new `future.unstable_passthroughRequests` future flag so that users still have a way to access the normalized URL when that flag is enabled and non-normalized `request`'s are being passed to your handlers. When adopting this flag, you will only need to start leveraging this new parameter if you are relying on the normalization of `request.url` in your application code. |
| 44 | + |
| 45 | + If you don't have the flag enabled, then `unstable_url` will match `request.url`. |
| 46 | + |
| 47 | +- Updated dependencies: |
| 48 | + - `react-router@7.13.2-pre.0` |
| 49 | + - `@react-router/node@7.13.2-pre.0` |
| 50 | + - `@react-router/serve@7.13.2-pre.0` |
| 51 | + |
3 | 52 | ## 7.13.1 |
4 | 53 |
|
5 | 54 | ### Patch Changes |
|
0 commit comments