M

react-router/6/useHistory-to-useNavigate

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 migrates useHistory to useNavigate in React Router codebases. It replaces useHistory imports and updates all instances of history.push, history.replace, go, goBack, and goForward to align with the useNavigate API.

Before

tsx

After

tsx

This codemod simplifies the migration from useHistory to useNavigate, aligning your code with React Router's latest navigation hooks while preserving functionality.

Ready to contribute?

Build your own codemod and share it with the community.