M

react-router/6/update-relative-links

How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

This codemod modernizes Route and Link components in React Router by:

  1. Removing the deprecated exact prop from Route.
  2. Updating Route to use the element prop.
  3. Rewriting dynamic Link and Route paths that use template literals like ${match.url} and ${match.path}.

Before

tsx

After

tsx

This ensures your code is compatible with newer versions of React Router, which no longer use exact and prefer the element prop for components. It also simplifies dynamic path generation by removing match references.

Ready to contribute?

Build your own codemod and share it with the community.