Upgrade React Router to v8#153
Open
sneridagh wants to merge 3 commits into
Open
Conversation
Bumps react-router, @react-router/dev, @react-router/node, and
@react-router/serve to 8.2.0, and remix-i18next to 8.0.0 (required,
since it only supports React Router v8 starting at its own v8).
- Migrate i18next.server.ts to remix-i18next's v8 middleware API
(createI18nextMiddleware), replacing the removed RemixI18Next class
and its /server, /client, /react subpath exports.
- Register the i18next middleware in root.tsx so getLocale/getInstance
work from route context; replace useChangeLanguage with a
useTranslation + useEffect sync.
- Fix explicit ns handling in the client and server i18next config:
defaultNS and ns are independent i18next options, so dropping the
namespace helpers without setting ns explicitly would have made the
app preload the wrong ("translation") namespace instead of "common".
- Rename unstable_pattern/unstable_url to pattern/url across loader and
action test helpers (now stable, unprefixed fields in v8).
- Update meta() functions in cmsui, contents, and publicui routes to
read match.loaderData instead of the removed match.data.
- Remove the now-default v8_middleware future flag.
- Bump apps/aurora engines to Node >=22.22.0.
Running pnpm install for the React Router upgrade had re-resolved prettier's unpinned devDependency range (packages/tooling: ^3.5.2) from 3.6.2 to 3.9.5, an unrelated side effect that would have caused prettier to reformat unrelated files across the repo. Restored the 3.6.2 resolution (matching main) without adding an override, so this PR stays scoped to the React Router upgrade.
The previous commit treated the prettier 3.6.2 -> 3.9.5 resolution bump as an unrelated side effect and pinned it back down. That was wrong: @react-router/dev@8.2.0 has a hard dependency on `prettier: ^3.8.3`, which packages/tooling's existing ^3.5.2 range (previously satisfied by 3.6.2) can no longer share a single resolved version with. pnpm's natural resolution of 3.9.5 (satisfying both ranges) is correct and necessary for this upgrade, not incidental drift to suppress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Upgrades React Router from 7.14.0 to 8.2.0 (
react-router,@react-router/dev,@react-router/node,@react-router/serve), andremix-i18nextfrom 7.1.0 to 8.0.0 (required, sinceremix-i18nextonly supports React Router v8 starting at its own v8).React Router v8's breaking changes are mostly the codification of flags that were already opt-in in v7 (
future.v8_middleware, which this app had already adopted), plus a couple of renamed fields. The bulk of this PR is migrating offremix-i18nextv7'sRemixI18Nextclass, which was removed in v8 in favor of a middleware-based API.React Router v8 changes
unstable_pattern/unstable_url→pattern/url: renamed (now stable, unprefixed) across loader/action test helpers inapps/aurora,packages/cmsui, andpackages/contents.MetaMatch.data→MetaMatch.loaderData: updatedmeta()functions incmsui,contents, andpublicuiroot layouts/routes that read the root route's loader data frommatches.future.v8_middlewareflag fromapps/aurora/react-router.config.ts.apps/auroraengines to Node>=22.22.0(v8's minimum).remix-i18next v8 migration
apps/aurora/app/i18next.server.tsto usecreateI18nextMiddleware, replacing the removedRemixI18Nextclass and its/server,/client,/reactsubpath exports. It now exports[i18nextMiddleware, getLocale, getInstance].i18nextMiddlewareinroot.tsx'smiddlewarearray sogetLocale(context)/getInstance(context)work from route context, and updated thecmsui,contents, andpublicuiroot layouts that independently calledi18next.getLocale(request)to use the new context-basedgetLocale.entry.server.tsxto render with the middleware-provided instance (getInstance(loadContext)) instead of manually creating and initializing a per-request i18next instance.useChangeLanguagehook inroot.tsx'sLayoutwith an equivalentuseTranslation+useEffectsync.defaultNSandnsare independent i18next options. The removedgetInitialNamespaces()/getRouteNamespaces()helpers previously supplied an explicitnsarray computed from matched routes. Simply dropping them (relying ondefaultNS: 'common'alone) would silently make i18next preload the wrongtranslationnamespace instead ofcommon, sincensdefaults independently to['translation']. Fixed by explicitly settingns: i18n.defaultNSin both the client (entry.client.tsx) and server (i18next.server.ts) init options.Dependency note: prettier bump (3.6.2 → 3.9.5)
@react-router/dev@8.2.0has a hard dependency onprettier: ^3.8.3, which the repo's previously-resolvedprettier@3.6.2(satisfyingpackages/tooling's^3.5.2range) can no longer share a single resolved version with. pnpm's natural resolution bumps the shared prettier install to3.9.5to satisfy both ranges. This is a required consequence of the upgrade, not incidental drift — earlier revisions of this PR mistakenly tried to pin it back down; that's been reverted. Note that prettier 3.9.5 has some formatting-rule differences from 3.6.2, so runningprettier --writerepo-wide after this merges may produce unrelated formatting diffs on files untouched by this PR; that's expected and best handled as its own follow-up formatting pass rather than bundled here.Test plan
pnpm install—remix-i18nextpeer warning againstreact-routeris goneapps/aurora,packages/cmsui,packages/publicui,packages/layout,packages/react-router(packages/contentshas pre-existing, unrelated type errors not touched by this change)apps/aurora(44/44),packages/cmsui(178/178),packages/contents(3/3),packages/layout(8/8),packages/react-router(5/5)pnpm build)pnpm start:prodboot: middleware chain, routing, and SSR run end-to-end (the resulting 500 is expected — no local Plone backend was running in the test environment; it renders via the app's ownErrorBoundary, confirming the request pipeline completed)prettier/eslintclean on all changed files