npm react-router-dom 6.0.0-alpha.4
v6.0.0-alpha.4

latest releases: 0.0.0-experimental-121725374, 0.0.0-nightly-68f43b8cd-20241119, 0.0.0-nightly-4af1d409c-20241118...
4 years ago

Lots of great stuff in this release, especially if you like Intellisense :)

Major Features

  • Migrated the core codebase to TypeScript and added TypeScript declarations
  • Added a migration guide for folks coming from reach/router
  • Added useInRouterContext hook for determining if you're in the context of a router or not
  • Added useLocationPending hook (experimental)
  • Added matchPath function for manually matching paths to URL pathnames

Note: experimental features rely on an experimental release of React and will probably be moved into a separate "experimental" release channel in the near future.

Major Changes

Warning: This release breaks compatibility with 6.0.0-alpha.3

  • useSearchParams now returns [searchParams, setSearchParams] (similar to useState). setSearchParams is a wrapper for navigate that updates the query string on the current URL. See the updated guide on working with the query string.
  • Removed the <StaticRouter context> API. We don't support navigation on the initial render in v6, so this API is unnecessary.
  • useMatch takes a route path (instead of a link to value as it did previously). It should have always taken a route path; this was just a simple oversight.

Bugfixes

  • Fixed a bug with multiple nested * routes
  • Force stable sort in browsers that don't have it so routes that otherwise rank equally maintain the order in which they were originally defined

Installing

Development for v6 is happening on the dev branch.

If you'd like to test it out, install from npm:

$ npm install react-router@next react-router-dom@next

Or, if you're on React Native:

$ yarn add react-router@next react-router-native@next

We are actively working on documentation. For now, if you're just interested in testing things out you may be interested in the getting started guide. If you're interested in upgrading an existing app, please check out the v5 to v6 migration guide.

Enjoy!

Don't miss a new react-router-dom release

NewReleases is sending notifications on new releases.