Conversation
By using react-router and react-router/dom imports as stated in documentation https://reactrouter.com/upgrading/v6#upgrade-to-v7
By using the right imports/mocks
After migrating to React Router v7, the test suite fails with the following error: > ReferenceError: TextEncoder is not defined This appears to be due to an unimplemented TextEncoder in jsdom. To resolve this, we follow the same workaround as React Router, as outlined in remix-run/react-router#12363 (comment)
It was introduced to work around React Router v6's issue of not encoding parameters in the generatePath function. However, after migrating to v7, tests began failing due to double encoding. This revealed that React Router v7 already handles encoding parameters in generatePath. See remix-run/react-router#13530 Thus, this commit reverts the changes made in #2576
In TypeScript, TextEncoder and TextDecoder are global types when targeting the DOM environment, causing conflicts when importing these classes from Node’s util module. To avoid these conflicts, TextEncoder and TextDecoder from util have been imported with different names (NodeTextEncoder, NodeTextDecoder) and assigned to globalThis with explicit type assertions. * MDN - https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder - https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder * StackOverflow - https://stackoverflow.com/a/77752064 * TypeScript types - https://github.com/microsoft/TypeScript/blob/efca03ffed10dccede4fbc8dd8a624374e5424d9/src/lib/dom.generated.d.ts#L32378
To fix an issue with React Router v7 types > src/index.tsx:25:32 - error TS2307: Cannot find module 'react-router/dom' or its corresponding type declarations. > There are types at 'node_modules/react-router/dist/development/dom-export.d.mts', > but this result could not be resolved under your current 'moduleResolution' setting. > Consider updating to 'node16', 'nodenext', or 'bundler'. As per TypeScript documentation, https://www.typescriptlang.org/tsconfig/#moduleResolution > 'bundler' for use with bundlers. Like node16 and nodenext, this mode > supports package.json "imports" and "exports", but unlike the Node.js > resolution modes, bundler never requires file extensions on relative > paths in imports.
imobachgs
approved these changes
Nov 10, 2025
Contributor
imobachgs
left a comment
There was a problem hiding this comment.
Reviewed commit per commit. Thanks!
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.
Problem
React Router v7 was released almost a year now (see https://reactrouter.com/changelog#v700), but it has not been updated in Agama yet. In addition to the obvious benefit of keeping dependencies up-to-date, updating it might help to address some limitations we have found with the v6 version, like 06d858c
Solution
Migrate React Router dependency to its latest version.
Testing
Notes
This migration has been straightforward, and as of now, Agama is using Data Mode (see https://reactrouter.com/start/modes). However, this could change in the future if we find advantages in switching to Declarative or Framework Mode. Before making any decisions, we’ll need to work on
src/App.tsxalong with the changes planned for the api-v2 branch that this PR is based on.Documentation
:paramvalues ingeneratePath()remix-run/react-router#13530 (generatePathnow encodes URL params by default, related to fix(web): encode URL params for safer URL generation #2576)