fix(deps): update react-router monorepo to v7 (major) #3363
+35
−18
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.30.0
->7.3.0
6.30.0
->7.3.0
Release Notes
remix-run/react-router (react-router)
v7.3.0
Compare Source
Minor Changes
Add
fetcherKey
as a parameter topatchRoutesOnNavigation
(#13061)fetcher
calls to undiscovered routes, this mismatch will trigger a document reload of the current pathPatch Changes
Skip resource route flow in dev server in SPA mode (#13113)
Support middleware on routes (unstable) (#12941)
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:
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>
):Fix types for loaderData and actionData that contained
Record
s (#13139)UNSTABLE(BREAKING):
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 on
unstable_SerializesTo
.To fix this, the branded property of
unstable_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
.[REMOVE] Remove middleware depth logic and always call middlware for all matches (#13172)
Fix single fetch
_root.data
requests when abasename
is used (#12898)Add
context
support to client side data routers (unstable) (#12941)Your application
loader
andaction
functions on the client will now receive acontext
parameter. This is an instance ofunstable_RouterContextProvider
that you use with type-safe contexts (similar toReact.createContext
) and is most useful with the correspondingmiddleware
/clientMiddleware
API's: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:v7.2.0
Compare Source
Minor Changes
New type-safe
href
utility that guarantees links point to actual paths in your app (#13012)Patch Changes
Fix typegen for repeated params (#13012)
In React Router, path parameters are keyed by their name.
So for a path pattern like
/a/:id/b/:id?/c/:id
, the last:id
will set the value forid
inuseParams
and theparams
prop.For example,
/a/1/b/2/c/3
will result in the value{ id: 3 }
at runtime.Previously, generated types for params incorrectly modeled repeated params with an array.
So
/a/1/b/2/c/3
generated a type like{ id: [1,2,3] }
.To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
So
/a/1/b/2/c/3
now generates a type like{ id: 3 }
.Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request (#12948)
Properly handle revalidations to across a prerender/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 submissionError at build time in
ssr: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 404Add unstable support for splitting route modules in framework mode via
future.unstable_splitRouteModules
(#11871)Add
unstable_SerializesTo
brand type for library authors to register types serializable by React Router's streaming format (turbo-stream
) (ab5b05b02
)Align dev server behavior with static file server behavior when
ssr:false
is set (#12948)prerender
config exists, only SSR down to the rootHydrateFallback
(SPA Mode)prerender
config exists but the current path is not prerendered, only SSR down to the rootHydrateFallback
(SPA Fallback).data
requests to non-pre-rendered pathsImprove prefetch performance of CSS side effects in framework mode (#12889)
Disable Lazy Route Discovery for all
ssr:false
apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured__manifest
requests (#12894)ssr:false
and noprerender
config but we realized it should apply to allssr:false
apps, including those prerendering multiple pagesprerender
scenarios we would prerender the/__manifest
file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviorsProperly handle interrupted manifest requests in lazy route discovery (#12915)
v7.1.5
Compare Source
Patch Changes
7.1.4
via #12800 that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (patchRoutesOnNavigation
) (#12927)v7.1.4
Compare Source
Patch Changes
text/plain
orapplication/json
responses (#12848).data
extension.data
request, they will still be encoded viaturbo-stream
querySelectorAll
call at thebody
level instead of many calls at the sub-tree level (#12731)errorHeaders
when throwing adata()
result (#12846)Set-Cookie
headers could be duplicated if also returned fromheaders
matchRoutes
calls when possible (#12800)v7.1.3
Compare Source
No changes
v7.1.2
Compare Source
Patch Changes
Fix issue with fetcher data cleanup in the data layer on fetcher unmount (#12681)
Do not rely on
symbol
for filtering outredirect
responses from loader data (#12694)Previously, some projects were getting type checking errors like:
Now that
symbol
s are not used for theredirect
response type, these errors should no longer be present.v7.1.1
Compare Source
No changes
v7.1.0
Compare Source
Patch Changes
<Link prefetch>
warning which suffers from false positives in a lazy route discovery world (#12485)v7.0.2
Compare Source
Patch Changes
temporarily only use one build in export map so packages can have a peer dependency on react router (#12437)
Generate wide
matches
andparams
types for current route and child routes (#12397)At runtime,
matches
includes child route matches andparams
include child route path parameters.But previously, we only generated types for parent routes in
matches
; forparams
, we only considered the parent routes and the current route.To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
v7.0.1
Compare Source
No changes
v7.0.0
Compare Source
Major Changes
Remove the original
defer
implementation in favor of using raw promises via single fetch andturbo-stream
. This removes these exports from React Router: (#11744)defer
AbortedDeferredError
type TypedDeferredData
UNSAFE_DeferredData
UNSAFE_DEFERRED_SYMBOL
,@remix-run/router
intoreact-router
(#11505)react-router-dom
intoreact-router
@remix-run/server-runtime
intoreact-router
@remix-run/testing
intoreact-router
Remove single_fetch future flag. (#11522)
Drop support for Node 16, React Router SSR now requires Node 18 or higher (#11391)
Remove
future.v7_startTransition
flag (#11696)useNavigate()
useSubmit
useFetcher().load
useFetcher().submit
useRevalidator.revalidate
Remove
future.v7_normalizeFormMethod
future flag (#11697)For Remix consumers migrating to React Router, the
crypto
global from the Web Crypto API is now required when using cookie and session APIs. This means that the following APIs are provided fromreact-router
rather than platform-specific packages: (#11837)createCookie
createCookieSessionStorage
createMemorySessionStorage
createSessionStorage
For consumers running older versions of Node, the
installGlobals
function from@remix-run/node
has been updated to defineglobalThis.crypto
, using Node'srequire('node:crypto').webcrypto
implementation.Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
createCookieFactory
createSessionStorageFactory
createCookieSessionStorageFactory
createMemorySessionStorageFactory
Imports/Exports cleanup (#11840)
@remix-run/router
AgnosticDataIndexRouteObject
AgnosticDataNonIndexRouteObject
AgnosticDataRouteMatch
AgnosticDataRouteObject
AgnosticIndexRouteObject
AgnosticNonIndexRouteObject
AgnosticRouteMatch
AgnosticRouteObject
TrackedPromise
unstable_AgnosticPatchRoutesOnMissFunction
Action
-> exported asNavigationType
viareact-router
Router
exported asDataRouter
to differentiate from RR's<Router>
getToPathname
(@private
)joinPaths
(@private
)normalizePathname
(@private
)resolveTo
(@private
)stripBasename
(@private
)createBrowserHistory
-> in favor ofcreateBrowserRouter
createHashHistory
-> in favor ofcreateHashRouter
createMemoryHistory
-> in favor ofcreateMemoryRouter
createRouter
createStaticHandler
-> in favor of wrappercreateStaticHandler
in RR DomgetStaticContextFromError
react-router
Hash
Pathname
Search
update minimum node version to 18 (#11690)
Remove
future.v7_prependBasename
from the ionternalized@remix-run/router
package (#11726)Migrate Remix type generics to React Router (#12180)
Route.*
typesRoute.*
typesuseFetcher
previously had an optional generic (used primarily by Remix v2) that expected the data typetypeof loader
/typeof action
)useFetcher<LoaderData>()
useFetcher<typeof loader>()
Remove
future.v7_throwAbortReason
from internalized@remix-run/router
package (#11728)Add
exports
field to all packages (#11675)node package no longer re-exports from react-router (#11702)
renamed RemixContext to FrameworkContext (#11705)
updates the minimum React version to 18 (#11689)
PrefetchPageDescriptor replaced by PageLinkDescriptor (#11960)
@remix-run/router
,@remix-run/server-runtime
, and@remix-run/react
now that they all live inreact-router
(#12177)LoaderFunction
,LoaderFunctionArgs
,ActionFunction
,ActionFunctionArgs
,DataFunctionArgs
,RouteManifest
,LinksFunction
,Route
,EntryRoute
RouteManifest
type used by the "remix" code is now slightly stricter because it is using the former@remix-run/router
RouteManifest
Record<string, Route> -> Record<string, Route | undefined>
AppData
type in favor of inliningunknown
in the few locations it was usedServerRuntimeMeta*
types in favor of theMeta*
types they were duplicated fromfuture.v7_partialHydration
flag (#11725)<RouterProvider fallbackElement>
propfallbackElement
to ahydrateFallbackElement
/HydrateFallback
on your root routefuture.v7_partialHydration
(when usingfallbackElement
),state.navigation
was populated during the initial loadfuture.v7_partialHydration
,state.navigation
remains in an"idle"
state during the initial loadRemove
v7_relativeSplatPath
future flag (#11695)Drop support for Node 18, update minimum Node vestion to 20 (#12171)
installGlobals()
as this should no longer be necessaryRemove remaining future flags (#11820)
v7_skipActionErrorRevalidation
v3_fetcherPersist
,v3_relativeSplatPath
,v3_throwAbortReason
rename createRemixStub to createRoutesStub (#11692)
Remove
@remix-run/router
deprecateddetectErrorBoundary
option in favor ofmapRouteProperties
(#11751)Add
react-router/dom
subpath export to properly enablereact-dom
as an optionalpeerDependency
(#11851)import ReactDOM from "react-dom"
in<RouterProvider>
in order to accessReactDOM.flushSync()
, since that would breakcreateMemoryRouter
use cases in non-DOM environmentsreact-router/dom
to get the proper component that makesReactDOM.flushSync()
available:entry.client.tsx
:import { HydratedRouter } from 'react-router/dom'
createBrowserRouter
/createHashRouter
:import { RouterProvider } from "react-router/dom"
Remove
future.v7_fetcherPersist
flag (#11731)Update
cookie
dependency to^1.0.1
- please see the release notes for any breaking changes (#12172)Minor Changes
prerender
config in the React Router vite plugin, to support existing SSG use-cases (#11539)prerender
config to pre-render your.html
and.data
files at build time and then serve them statically at runtime (either from a running server or a CDN)prerender
can either be an array of string paths, or a function (sync or async) that returns an array of strings so that you can dynamically generate the paths by talking to your CMS, etc.Params, loader data, and action data as props for route component exports (#11961)
Remove duplicate
RouterProvider
impliementations (#11679)Typesafety improvements (#12019)
React Router now generates types for each of your route modules.
You can access those types by importing them from
./+types.<route filename without extension>
.For example:
This initial implementation targets type inference for:
Params
: Path parameters from your routing config inroutes.ts
including file-based routingLoaderData
: Loader data fromloader
and/orclientLoader
within your route moduleActionData
: Action data fromaction
and/orclientAction
within your route moduleIn the future, we plan to add types for the rest of the route module exports:
meta
,links
,headers
,shouldRevalidate
, etc.We also plan to generate types for typesafe
Link
s:Check out our docs for more:
Stabilize
unstable_dataStrategy
(#11969)Stabilize
unstable_patchRoutesOnNavigation
(#11970)Patch Changes
No changes (
506329c4e
)chore: re-enable development warnings through a
development
exports condition. (#12269)Remove unstable upload handler. (#12015)
Remove unneeded dependency on @web3-storage/multipart-parser (#12274)
Fix redirects returned from loaders/actions using
data()
(#12021)fix(react-router): (v7) fix static prerender of non-ascii characters (#12161)
Replace
substr
withsubstring
(#12080)Remove the deprecated
json
utility (#12146)Response.json
if you still need to construct JSON responses in your appRemove unneeded dependency on source-map (#12275)
remix-run/react-router (react-router-dom)
v7.3.0
Compare Source
Patch Changes
react-router@7.3.0
v7.2.0
Compare Source
Patch Changes
react-router@7.2.0
v7.1.5
Compare Source
Patch Changes
react-router@7.1.5
v7.1.4
Compare Source
Patch Changes
react-router@7.1.4
v7.1.3
Compare Source
Patch Changes
react-router@7.1.3
v7.1.2
Compare Source
Patch Changes
react-router@7.1.2
v7.1.1
Compare Source
Patch Changes
react-router@7.1.1
v7.1.0
Compare Source
Patch Changes
react-router@7.1.0
v7.0.2
Compare Source
Patch Changes
react-router@7.0.2
v7.0.1
Compare Source
Patch Changes
react-router@7.0.1
v7.0.0
Compare Source
Major Changes
Remove the original
defer
implementation in favor of using raw promises via single fetch andturbo-stream
. This removes these exports from React Router: (#11744)defer
AbortedDeferredError
type TypedDeferredData
UNSAFE_DeferredData
UNSAFE_DEFERRED_SYMBOL
,Use
createRemixRouter
/RouterProvider
inentry.client
instead ofRemixBrowser
(#11469)Remove single_fetch future flag. (#11522)
Remove
future.v7_startTransition
flag (#11696)Remove
future.v7_normalizeFormMethod
future flag (#11697)Allow returning
undefined
from actions and loaders (#11680)update minimum node version to 18 (#11690)
Remove
future.v7_prependBasename
from the ionternalized@remix-run/router
package (#11726)Remove
future.v7_throwAbortReason
from internalized@remix-run/router
package (#11728)Add
exports
field to all packages (#11675)node package no longer re-exports from react-router (#11702)
updates the minimum React version to 18 (#11689)
future.v7_partialHydration
flag (#11725)<RouterProvider fallbackElement>
propfallbackElement
to ahydrateFallbackElement
/HydrateFallback
on your root routefuture.v7_partialHydration
(when usingfallbackElement
),state.navigation
was populated during the initial loadfuture.v7_partialHydration
,state.navigation
remains in an"idle"
state during the initial loadRemove
future.v7_fetcherPersist
flag (#11731)Minor Changes
Link
/NavLink
when using Remix SSR (#11402)ScrollRestoration
so it can restore properly on an SSR'd document load (#11401)RouterProvider
. When running from a Remix-SSR'd HTML payload with the properwindow
variables (__remixContext
,__remixManifest
,__remixRouteModules
), you don't need to pass arouter
prop andRouterProvider
will create therouter
for you internally. (#11396) (#11400)Patch Changes
RouterProvider
internals to reduce uneccesary re-renders (#11817)react-router@7.0.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), 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 these updates again.
This PR was generated by Mend Renovate. View the repository job log.