Update dependency remix-run/react-router to v7 #276
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
6.28.2
->7.5.1
Release Notes
remix-run/react-router (remix-run/react-router)
v7.5.1
Compare Source
Date: 2025-04-17
Patch Changes
react-router
- When using the object-basedroute.lazy
API, theHydrateFallback
andhydrateFallbackElement
properties are now skipped when lazy loading routes after hydration (#13376)If you move the code for these properties into a separate file, since the hydrate properties were unused already (if the route wasn't present during hydration), you can avoid downloading them at all. For example:
react-router
- Fix single fetch bug where no revalidation request would be made when navigating upwards to a reused parent route (#13253)react-router
- Properly revalidate pre-rendered paths when param values change when usingssr:false
+prerender
configs (#13380)react-router
- Fix pre-rendering when a loader returns a redirect (#13365)react-router
- Do not automatically addnull
tostaticHandler.query()
context.loaderData
if routes do not have loaders (#13223)undefined
from loaders, our prior check ofloaderData[routeId] !== undefined
was no longer sufficient and was changed to arouteId in loaderData
check - thesenull
values can cause issues for this new checkcreateStaticHandler()
/<StaticRouterProvider>
, and usingcontext.loaderData
to control<RouterProvider>
hydration behavior on the clientUnstable Changes
react-router
- Add better error messaging whengetLoadContext
is not updated to return aMap
(#13242)react-router
- Update context type forLoaderFunctionArgs
/ActionFunctionArgs
when middleware is enabled (#13381)react-router
- Add a newunstable_runClientMiddleware
argument todataStrategy
to enable middleware execution in customdataStrategy
implementations (#13395)react-router
- Add support for the newunstable_shouldCallHandler
/unstable_shouldRevalidateArgs
APIs indataStrategy
(#13253)Full Changelog:
v7.5.0...v7.5.1
v7.5.0
Compare Source
Date: 2025-04-04
What's Changed
route.lazy
Object APIWe've introduced a new
route.lazy
API which gives you more granular control over the lazy loading of route properties that you could not achieve with theroute.lazy()
function signature. This is useful for Framework mode and performance-critical library mode applications.route.unstable_lazyMiddleware
API which has been removed in favor ofroute.lazy.unstable_middleware
. See theUnstable Changes
section below for more information.Minor Changes
react-router
- Add granular object-based API forroute.lazy
to support lazy loading of individual route properties (#13294)Patch Changes
@react-router/dev
- Update optionalwrangler
peer dependency range to supportwrangler
v4 (#13258)@react-router/dev
- Reinstate dependency optimization in the child compiler to fixdepsOptimizer is required in dev mode
errors when usingvite-plugin-cloudflare
and importing Node.js builtins (#13317)Unstable Changes
react-router
- Introducefuture.unstable_subResourceIntegrity
flag that enables generation of animportmap
withintegrity
for the scripts that will be loaded by the browser (#13163)react-router
- Remove support for theroute.unstable_lazyMiddleware
property (#13294)route.lazy.unstable_middleware
API@react-router/dev
- Whenfuture.unstable_viteEnvironmentApi
is enabled, ensure critical CSS in development works when using a custom Vitebase
has been configured (#13305)Changes by Package
create-react-router
react-router
@react-router/architect
@react-router/cloudflare
@react-router/dev
@react-router/express
@react-router/fs-routes
@react-router/node
@react-router/remix-config-routes-adapter
@react-router/serve
Full Changelog:
v7.4.1...v7.5.0
v7.4.1
Compare Source
Date: 2025-03-28
Security Notice
Fixed a security vulnerability that allowed URL manipulation and potential cache pollution via the
Host
andX-Forwarded-Host
headers due to inadequate port sanitization.Patch Changes
react-router
- Dedupe calls toroute.lazy
functions (#13260)@react-router/dev
- Fix path in prerender error messages (#13257)@react-router/dev
- Fix typegen for virtual modules whenmoduleDetection
is set toforce
(#13267)@react-router/express
- Better validation ofx-forwarded-host
header to prevent potential security issues (#13309)Unstable Changes
react-router
- Fix types onunstable_MiddlewareFunction
to avoid type errors when a middleware doesn't return a value (#13311)react-router
- Add support forroute.unstable_lazyMiddleware
function to allow lazy loading of middleware logic (#13210)unstable_middleware
fromroute.lazy
route.unstable_middleware
property is no longer supported in the return value fromroute.lazy
route.unstable_lazyMiddleware
@react-router/dev
- When bothfuture.unstable_middleware
andfuture.unstable_splitRouteModules
are enabled, splitunstable_clientMiddleware
route exports into separate chunks when possible (#13210)@react-router/dev
- Improve performance offuture.unstable_middleware
by ensuring that route modules are only blocking during the middleware phase when theunstable_clientMiddleware
has been defined (#13210)Full Changelog:
v7.4.0...v7.4.1
v7.4.0
Compare Source
Date: 2025-03-19
Minor Changes
@react-router/dev
- Generate types forvirtual:react-router/server-build
module (#13152)Patch Changes
react-router
- Fix root loader data on initial load redirects in SPA mode (#13222)react-router
- Load ancestor pathless/index routes in lazy route discovery for upwards non-eager-discovery routing (#13203)react-router
- FixshouldRevalidate
behavior forclientLoader
-only routes inssr:true
apps (#13221)@react-router/dev
- Fix conflicts with other Vite plugins that use theconfigureServer
and/orconfigurePreviewServer
hooks (#13184)Unstable Changes
react-router
- If a middleware throws an error, ensure we only bubble the error itself vianext()
and are no longer leaking theMiddlewareError
implementation detail (#13180)catch
-ing errors thrown by thenext()
function in your middlewaresreact-router
- FixRequestHandler
loadContext
parameter type when middleware is enabled (#13204)react-router
- UpdateRoute.unstable_MiddlewareFunction
to have a return value ofResponse | undefined
instead ofResponse | void
(#13199)@react-router/dev
- Whenfuture.unstable_splitRouteModules
is set to"enforce"
, allow both splittable and unsplittable root route exports since it's always in a single chunk (#13238)@react-router/dev
- Whenfuture.unstable_viteEnvironmentApi
is enabled, allow plugins that override the default SSR environment (such as@cloudflare/vite-plugin
) to be placed before or after the React Router plugin (#13183)Changes by Package
create-react-router
react-router
@react-router/architect
@react-router/cloudflare
@react-router/dev
@react-router/express
@react-router/fs-routes
@react-router/node
@react-router/remix-config-routes-adapter
@react-router/serve
Full Changelog:
v7.3.0...v7.4.0
v7.3.0
Compare Source
Date: 2025-03-06
Minor Changes
fetcherKey
as a parameter topatchRoutesOnNavigation
(#13061)Patch Changes
react-router
- Detect and handle manifest-skew issues on new deploys during active sessions (#13061)fetcher
calls to undiscovered routes, this mismatch will trigger a document reload of the current pathreact-router
- Skip resource route flow in dev server in SPA mode (#13113)react-router
- Fix single fetch_root.data
requests when abasename
is used (#12898)react-router
- Fix types forloaderData
andactionData
that containedRecord
s (#13139)unstable_SerializesTo
- see the note in theUnstable Changes
section below for more information@react-router/dev
- Fix support for custom clientbuild.rollupOptions.output.entryFileNames
(#13098)@react-router/dev
- Fix usage ofprerender
option whenserverBundles
option has been configured or provided by a preset, e.g.vercelPreset
from@vercel/react-router
(#13082)@react-router/dev
- Fix support for custombuild.assetsDir
(#13077)@react-router/dev
- Remove unused dependencies (#13134)@react-router/dev
- Stub all routes except root in "SPA Mode" server builds to avoid issues when route modules or their dependencies import non-SSR-friendly modules (#13023)@react-router/dev
- Remove unused Vite file system watcher (#13133)@react-router/dev
- Fix support for custom SSR build input whenserverBundles
option has been configured (#13107)future.unstable_viteEnvironmentApi
andserverBundles
options together, hyphens are no longer supported in server bundle IDs since they also need to be valid Vite environment names.@react-router/dev
- Fix dev server when using HTTPS by stripping HTTP/2 pseudo headers from dev server requests (#12830)@react-router/dev
- Lazy load Cloudflare platform proxy on first dev server request when using thecloudflareDevProxy
Vite plugin to avoid creating unnecessaryworkerd
processes (#13016)@react-router/dev
- Fix duplicated entries in typegen for layout routes and their corresponding index route (#13140)@react-router/express
- Updateexpress
peerDependency
to include v5 (https://github.com/remix-run/react-router/pull/13064) (#12961)Unstable Changes
react-router
- Addcontext
support to client side data routers (unstable) (#12941)react-router
- Support middleware on routes (unstable) (#12941)@react-router/dev
- Fix errors withfuture.unstable_viteEnvironmentApi
when thessr
environment has been configured by another plugin to be a customVite.DevEnvironment
rather than the defaultVite.RunnableDevEnvironment
(#13008)@react-router/dev
- Whenfuture.unstable_viteEnvironmentApi
is enabled and thessr
environment hasoptimizeDeps.noDiscovery
disabled, defineoptimizeDeps.entries
andoptimizeDeps.include
(#13007)Client-side
context
(unstable)Your application
clientLoader
/clientAction
functions (orloader
/action
in library mode) will now receive acontext
parameter on the client. This is an instance ofunstable_RouterContextProvider
that you use with type-safe contexts (similar toReact.createContext
) and is most useful with the correspondingunstable_clientMiddleware
API:Similar to server-side requests, a fresh
context
will be created per navigation (orfetcher
call). If you have initial data you'd like to populate in the context for every request, you can provide anunstable_getContext
function at the root of your app:createBrowserRouter(routes, { unstable_getContext })
<HydratedRouter unstable_getContext>
This function should return an value of type
unstable_InitialContext
which is aMap<unstable_RouterContext, unknown>
of context's and initial values:Middleware (unstable)
Middleware is implemented behind a
future.unstable_middleware
flag. To enable, you must enable the flag and the types in yourreact-router.config.ts
file:clientMiddleware
that we will be addressing this before a stable release.context
parameter passed to yourloader
/action
functions - see below for more information.Once enabled, routes can define an array of middleware functions that will run sequentially before route handlers run. These functions accept the same parameters as
loader
/action
plus an additionalnext
parameter to run the remaining data pipeline. This allows middlewares to perform logic before and after handlers execute.Here's a simple example of a client-side logging middleware that can be placed on the root route:
Note that in the above example, the
next
/middleware
functions don't return anything. This is by design as on the client there is no "response" to send over the network like there would be for middlewares running on the server. The data is all handled behind the scenes by the statefulrouter
.For a server-side middleware, the
next
function will return the HTTPResponse
that React Router will be sending across the wire, thus giving you a chance to make changes as needed. You may throw a new response to short circuit and respond immediately, or you may return a new or altered response to override the default returned bynext()
.You can throw a
redirect
from a middleware to short circuit any remaining processing:Note that in cases like this where you don't need to do any post-processing you don't need to call the
next
function or return aResponse
.Here's another example of using a server middleware to detect 404s and check the CMS for a redirect:
For more information on the
middleware
API/design, please see the decision doc.Middleware
context
parameterWhen middleware is enabled, your application will use a different type of
context
parameter in your loaders and actions to provide better type safety. Instead ofAppLoadContext
,context
will now be an instance ofContextProvider
that you can use with type-safe contexts (similar toReact.createContext
):If you are using a custom server with a
getLoadContext
function, the return value for initial context values passed from the server adapter layer is no longer an object and should now return anunstable_InitialContext
(Map<RouterContext, unknown>
):unstable_SerializesTo
unstable_SerializesTo
added a way to register custom serialization types in Single Fetch for other library and framework authors like Apollo. It was implemented with branded type whose branded property that was made optional so that casting arbitrary values was easy:However, this broke type inference in
loaderData
andactionData
for anyRecord
types as those would now (incorrectly) matchunstable_SerializesTo
. This affected all users, not just those that depended onunstable_SerializesTo
. To fix this, the branded property ofunstable_SerializesTo
is marked as required instead of optional.For library and framework authors using
unstable_SerializesTo
, you may need to addas unknown
casts before casting tounstable_SerializesTo
.Changes by Package
create-react-router
react-router
@react-router/architect
@react-router/cloudflare
@react-router/dev
@react-router/express
@react-router/fs-routes
@react-router/node
@react-router/remix-config-routes-adapter
@react-router/serve
Full Changelog:
v7.2.0...v7.3.0
v7.2.0
Compare Source
Date: 2025-02-18
What's Changed
Type-safe
href
utilityIn framework mode, we now provide you with a fully type-safe
href
utility to give you all the warm and fuzzy feelings of path auto-completion and param validation for links in your application:You'll now get type errors if you pass a bad path value or a bad param value:
Prerendering with a SPA Fallback
This release enhances the ability to use a combination of pre-rendered paths alongside other paths that operate in "SPA Mode" when pre-rendering with
ssr:false
.ssr:false
without aprerender
config, this is considered "SPA Mode" and the generatedindex.html
file will only render down to the root route and will be able to hydrate for any valid application pathssr:false
with aprerender
config but do not include the/
path (i.e.,prerender: ['/blog/post']
), then we still generate a "SPA Mode"index.html
file that can hydrate for any path in the applicationssr:false
and include the/
path in yourprerender
config, the generatedindex.html
file will be specific to the root index route, so we will now also generate a separate "SPA Mode" file in__spa-fallback.html
that you can serve/hydrate for non-prerendered pathsFor more info, see the Pre-rendering docs for more info.
Allow a root
loader
in SPA ModeSPA Mode used to prohibit the use of loaders in all routes so that we could hydrate for any path in the application. However, because the root route is always rendered at build time, we can lift this restriction for the root route.
In order to use your build-time loader data during pre-rendering, we now also expose the
loaderData
as an optional prop for theHydrateFallback
component on routes:HydrateFallback
is rendering because children routes are loadingundefined
if theHydrateFallback
is rendering because the route itself has it's own hydratingclientLoader
Minor Changes
react-router
- New type-safehref
utility that guarantees links point to actual paths in your app (#13012)@react-router/dev
- Generate a "SPA fallback" HTML file when pre-rendering the/
route withssr:false
(#12948)@react-router/dev
- Allow aloader
in the root route in SPA mode because it can be called/server-rendered at build time (#12948)Route.HydrateFallbackProps
now also receivesloaderData
Patch Changes
react-router
- Disable Lazy Route Discovery for allssr:false
apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured__manifest
requests (#12894)ssr:false
appsprerender
scenarios we would pre-render the/__manifest
file but that makes some unnecessary assumptions about the static file server behaviorsreact-router
- Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request (#12948)react-router
- Properly handle revalidations to across a pre-render/SPA boundary (#13021).data
requests if the path wasn't pre-rendered because the request will 404loader
data inssr:false
mode is static because it's generated at build timeclientLoader
to do anything dynamicloader
and not aclientLoader
, we disable revalidation by default because there is no new data to retrieve.data
request logic if there are no server loaders withshouldLoad=true
in our single fetchdataStrategy
.data
request that would 404 after a submissionreact-router
- Align dev server behavior with static file server behavior whenssr:false
is set (#12948)prerender
config exists, only SSR down to the rootHydrateFallback
(SPA Mode)prerender
config exists but the current path is not pre-rendered, only SSR down to the rootHydrateFallback
(SPA Fallback).data
requests to non-pre-rendered pathsreact-router
- Improve prefetch performance of CSS side effects in framework mode (#12889)react-router
- Properly handle interrupted manifest requests in lazy route discovery (#12915)@react-router/dev
- Handle customenvDir
in Vite config (#12969)@react-router/dev
- Fix CLI parsing to allow argument-lessnpx react-router
usage (#12925)@react-router/dev
- Skip action-only resource routes when usingprerender:true
(#13004)@react-router/dev
- Enhance invalid export detection when usingssr:false
(#12948)headers
/action
functions are prohibited in all routes withssr:false
because there will be no runtime server on which to run themloader
functions are more nuanced and depend on whether a given route is prerenderedssr:false
without aprerender
config, only theroot
route can have aloader
ssr:false
with aprerender
config, only routes matched by aprerender
path can have aloader
@react-router/dev
- Error at build time inssr:false
+prerender
apps for the edge case scenario of: (#13021)loader
(does not have aclientLoader
)loaderData
because there is no server on which to run theloader
clientLoader
or pre-rendering the child pathsclientLoader
, calling theserverLoader()
on non-prerendered paths will throw a 404@react-router/dev
- Limit prerendered resource route.data
files to only the target route (#13004)@react-router/dev
- Fix pre-rendering of binary files (#13039)@react-router/dev
- Fix typegen for repeated params (#13012)/a/:id/b/:id?/c/:id
, the last:id
will set the value forid
inuseParams
and theparams
prop/a/1/b/2/c/3
will result in the value{ id: 3 }
at runtime/a/1/b/2/c/3
generated a type like{ id: [1,2,3] }
./a/1/b/2/c/3
now generates a type like{ id: 3 }
.@react-router/dev
- Fix path to loadpackage.json
forreact-router --version
(#13012)Unstable Changes
react-router
- Addunstable_SerializesTo
brand type for library authors to register types serializable by React Router's streaming format (turbo-stream
) (#12264)@react-router/dev
- Add unstable support for splitting route modules in framework mode viafuture.unstable_splitRouteModules
(#11871)@react-router/dev
- Addfuture.unstable_viteEnvironmentApi
flag to enable experimental Vite Environment API support (#12936)Split Route Modules (unstable)
One of the conveniences of the Route Module API is that everything a route needs is in a single file. Unfortunately this comes with a performance cost in some cases when using the
clientLoader
,clientAction
, andHydrateFallback
APIs.As a basic example, consider this route module:
In this example we have a minimal
clientLoader
export that makes a basic fetch call, whereas the default component export is much larger. This is a problem for performance because it means that if we want to navigate to this route client-side, the entire route module must be downloaded before the client loader can start running.To visualize this as a timeline:
In the following timeline diagrams, different characters are used within the Route Module bars to denote the different Route Module APIs being exported.
Instead, we want to optimize this to the following:
To achieve this optimization, React Router will split the route module into multiple smaller modules during the production build process. In this case, we'll end up with two separate virtual modules — one for the client loader and one for the component and its dependencies.
Now that these are available as separate modules, the client loader and the component can be downloaded in parallel. This means that the client loader can be executed as soon as it's ready without having to wait for the component.
This optimization is even more pronounced when more Route Module APIs are used. For example, when using
clientLoader
,clientAction
andHydrateFallback
, the timeline for a single route module during a client-side navigation might look like this:This would instead be optimized to the following:
Note that this optimization only works when the Route Module APIs being split don't share code within the same file. For example, the following route module can't be split:
This route will still work, but since both the client loader and the component depend on the
shared
function defined within the same file, it will be de-optimized into a single route module.To avoid this, you can extract any code shared between exports into a separate file. For example:
You can then import this shared code in your route module without triggering the de-optimization:
Since the shared code is in its own module, React Router is now able to split this route module into two separate virtual modules:
If your project is particularly performance sensitive, you can set the
unstable_splitRouteModules
future flag to"enforce"
:This setting will raise an error if any route modules can't be split:
Changes by Package
create-react-router
react-router
@react-router/architect
@react-router/cloudflare
@react-router/dev
@react-router/express
@react-router/fs-routes
@react-router/node
@react-router/remix-config-routes-adapter
@react-router/serve
Full Changelog:
v7.1.5...v7.2.0
v7.1.5
Compare Source
Date: 2025-01-31
Patch Changes
react-router
- Fix regression introduced in7.1.4
via #12800 that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (patchRoutesOnNavigation
) (#12927)Full Changelog:
v7.1.4...v7.1.5
v7.1.4
Compare Source
Date: 2025-01-30
Patch Changes
@react-router/dev
- Properly resolve Windows file paths to scan for Vite's dependency optimization when using theunstable_optimizeDeps
future flag (#12637)@react-router/dev
- Fix prerendering when using a custom server - previously we ended up trying to import the users custom server when we actually want to import the virtual server build module (#12759)react-router
- Properly handle status codes that cannot have a body in single fetch responses (204, etc.) (#12760)react-router
- Properly bubble headers aserrorHeaders
when throwing adata()
result (#12846)Set-Cookie
headers if also returned fromheaders
react-router
- Stop erroring on resource routes that return raw strings/objects and instead serialize them astext/plain
orapplication/json
responses (#12848).data
extension.data
request, they will still be encoded viaturbo-stream
react-router
- Optimize Lazy Route Discovery path discovery to favor a singlequerySelectorAll
call at thebody
level instead of many calls at the sub-tree level (#12731)react-router
- Optimize route matching by skipping redundantmatchRoutes
calls when possible (#12800, #12882)react-router
- Internal reorg to clean up some duplicated route module types (#12799)Full Changelog:
v7.1.3...v7.1.4
v7.1.2
Compare Source
Date: 2025-01-16
Patch Changes
react-router
- Fix issue with fetcher data cleanup in the data layer on fetcher unmount (#12681)react-router
- Do not rely onsymbol
for filtering outredirect
responses from loader data (#12694)symbol
s are not used for theredirect
response type, these errors should no longer be present@react-router/dev
- Fix default external conditions in Vite v6 (#12644)@react-router/dev
- Fix mismatch in prerendering html/data files when path is missing a leading slash (#12684)@react-router/dev
- Usemodule-sync
server condition when enabled in the runtime. This fixes React context mismatches (e.g.useHref() may be used only in the context of a <Router> component.
) during development on Node 22.10.0+ when using libraries that have a peer dependency on React Router (#12729)@react-router/dev
- Fixreact-refresh
source maps (#12686)Full Changelog:
v7.1.1...v7.1.2
v7.1.1
Compare Source
Date: 2024-12-23
Patch Changes
@react-router/dev
- Fix for a crash when optional args are passed to the CLI (#12609)Full Changelog:
v7.1.0...v7.1.1
v7.1.0
Compare Source
Date: 2024-12-20
Minor Changes
Patch Changes
react-router
- Throw unwrapped Single Fetchredirect
to align with pre-Single Fetch behavior (#12506)react-router
- Ignore redirects when inferring loader data types (#12527)react-router
- Remove<Link prefetch>
warning which suffers from false positives in a lazy route discovery world (#12485)create-react-router
- Fix missingfs-extra
dependency (#12556)@react-router/dev
/@react-router/serve
- Properly initializeNODE_ENV
if not already set for compatibility with React 19 (#12578)@react-router/dev
- Remove the leftover/unusedabortDelay
prop fromServerRouter
and update the defaultentry.server.tsx
to use the newstreamTimeout
value for Single Fetch (#12478)abortDelay
functionality was removed in v7 as it was coupled to thedefer
implementation from Remix v2, but this removal of this prop was missedentry.server
file, it's likely your app is not aborting streams as you would expect and you will need to adopt the newstreamTimeout
value introduced with Single Fetch@react-router/fs-routes
- Throw error inflatRoutes
if routes directory is missing (#12407)Changes by Package
create-react-router
react-router
@react-router/architect
Configuration
📅 Schedule: Branch creation - Between 12:00 AM and 03:59 AM, only on Monday ( * 0-3 * * 1 ) (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.