Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
run: pnpm build

- name: Publish to npm and create releases
run: pnpm changes:publish -- --branch=${{ github.ref_name }}
run: pnpm changes:publish --branch=${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
185 changes: 185 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@

[npm-badge]: https://img.shields.io/npm/v/react-router.svg
[npm]: https://www.npmjs.org/package/react-router
[build-badge]: https://img.shields.io/github/actions/workflow/status/remix-run/react-router/test.yml?branch=dev&style=square
[build-badge]: https://img.shields.io/github/actions/workflow/status/remix-run/react-router/test-unit.yml?branch=main&style=square
[build]: https://github.com/remix-run/react-router/actions/workflows/test-unit.yml

React Router is a multi-strategy router for React bridging the gap from React 18 to React 19. You can use it maximally as a React framework or minimally as a library with your own architecture.
React Router is a multi-strategy router for React. You can use it maximally as a React framework or minimally as a library with your own architecture.

- [Getting Started - Framework](https://reactrouter.com/start/framework/installation)
- [Getting Started - Library](https://reactrouter.com/start/library/installation)
- [Upgrade from v6](https://reactrouter.com/upgrading/v6)
- [Upgrade from Remix](https://reactrouter.com/upgrading/remix)
- [Upgrade from v7](https://reactrouter.com/upgrading/v7)
- [Changelog](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md)

## Packages

- [`react-router`](./packages/react-router)
- [`create-react-router`](./packages/create-react-router)
- [`@react-router/dev`](./packages/react-router-dev)
- [`@react-router/node`](./packages/react-router-node)
- [`@react-router/cloudflare`](./packages/react-router-cloudflare)
- [`@react-router/serve`](./packages/react-router-serve)
- [`@react-router/express`](./packages/react-router-express)
- [`@react-router/architect`](./packages/react-router-architect)
- [`@react-router/cloudflare`](./packages/react-router-cloudflare)
- [`@react-router/fs-routes`](./packages/react-router-fs-routes)

## Previous Versions

- [v7](https://reactrouter.com/v7)
- [v6](https://reactrouter.com/v6)
- [v5](https://v5.reactrouter.com/)
2 changes: 1 addition & 1 deletion docs/api/components/Await.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Await.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Await.html)

Used to render promise values with automatic error handling.

Expand Down
6 changes: 3 additions & 3 deletions docs/api/components/Form.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Form.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Form.html)

A progressively enhanced HTML [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
that submits data to actions via [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch),
Expand All @@ -38,7 +38,7 @@ enabling web application user experiences.
`Form` is most useful for submissions that should also change the URL or
otherwise add an entry to the browser history stack. For forms that shouldn't
manipulate the browser [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
stack, use [`<fetcher.Form>`](https://api.reactrouter.com/v7/types/react-router.FetcherWithComponents.html#Form).
stack, use [`<fetcher.Form>`](https://api.reactrouter.com/v8/types/react-router.FetcherWithComponents.html#Form).

```tsx
import { Form } from "react-router";
Expand Down Expand Up @@ -114,7 +114,7 @@ completion of the navigation when using the
Determines whether the form action is relative to the route hierarchy or
the pathname. Use this if you want to opt out of navigating the route
hierarchy and want to instead route based on slash-delimited URL segments.
See [`RelativeRoutingType`](https://api.reactrouter.com/v7/types/react-router.RelativeRoutingType.html).
See [`RelativeRoutingType`](https://api.reactrouter.com/v8/types/react-router.RelativeRoutingType.html).

### reloadDocument

Expand Down
4 changes: 2 additions & 2 deletions docs/api/components/Link.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Link.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Link.html)

A progressively enhanced [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
wrapper to enable navigation with client-side routing.
Expand Down Expand Up @@ -185,7 +185,7 @@ This state is inaccessible on the server as it is implemented on top of

[modes: framework, data, declarative]

Can be a string or a partial [`Path`](https://api.reactrouter.com/v7/interfaces/react-router.Path.html):
Can be a string or a partial [`Path`](https://api.reactrouter.com/v8/interfaces/react-router.Path.html):

```tsx
<Link to="/some/path" />
Expand Down
2 changes: 1 addition & 1 deletion docs/api/components/Links.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Links.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Links.html)

Renders all the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
tags created by the route module's [`links`](../../start/framework/route-module#links)
Expand Down
2 changes: 1 addition & 1 deletion docs/api/components/Meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Meta.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Meta.html)

Renders all the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta)
tags created by the route module's [`meta`](../../start/framework/route-module#meta)
Expand Down
14 changes: 7 additions & 7 deletions docs/api/components/NavLink.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.NavLink.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.NavLink.html)

Wraps [`<Link>`](../components/Link) with additional props for styling active and
pending states.

- Automatically applies classes to the link based on its `active` and `pending`
states, see [`NavLinkProps.className`](https://api.reactrouter.com/v7/interfaces/react-router.NavLinkProps.html#className)
states, see [`NavLinkProps.className`](https://api.reactrouter.com/v8/interfaces/react-router.NavLinkProps.html#className)
- Note that `pending` is only available with Framework and Data modes.
- Automatically applies `aria-current="page"` to the link when the link is active.
See [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
on MDN.
- States are additionally available through the className, style, and children
render props. See [`NavLinkRenderProps`](https://api.reactrouter.com/v7/types/react-router.NavLinkRenderProps.html).
render props. See [`NavLinkRenderProps`](https://api.reactrouter.com/v8/types/react-router.NavLinkRenderProps.html).

```tsx
<NavLink to="/message">Messages</NavLink>
Expand Down Expand Up @@ -94,7 +94,7 @@ a.transitioning {
}
```

Or you can specify a function that receives [`NavLinkRenderProps`](https://api.reactrouter.com/v7/types/react-router.NavLinkRenderProps.html) and
Or you can specify a function that receives [`NavLinkRenderProps`](https://api.reactrouter.com/v8/types/react-router.NavLinkRenderProps.html) and
returns the `className`:

```tsx
Expand Down Expand Up @@ -125,7 +125,7 @@ Defines the link [lazy route discovery](../../explanation/lazy-route-discovery)
[modes: framework, data, declarative]

Changes the matching logic for the `active` and `pending` states to only match
to the "end" of the [`NavLinkProps.to`](https://api.reactrouter.com/v7/interfaces/react-router.NavLinkProps.html#to). If the URL is longer, it will no
to the "end" of the [`NavLinkProps.to`](https://api.reactrouter.com/v8/interfaces/react-router.NavLinkProps.html#to). If the URL is longer, it will no
longer be considered active.

| Link | URL | isActive |
Expand Down Expand Up @@ -269,7 +269,7 @@ This state is inaccessible on the server as it is implemented on top of
[modes: framework, data, declarative]

Styles can also be applied dynamically via a function that receives
[`NavLinkRenderProps`](https://api.reactrouter.com/v7/types/react-router.NavLinkRenderProps.html) and returns the styles:
[`NavLinkRenderProps`](https://api.reactrouter.com/v8/types/react-router.NavLinkRenderProps.html) and returns the styles:

```tsx
<NavLink to="/tasks" style={{ color: "red" }} />
Expand All @@ -284,7 +284,7 @@ Styles can also be applied dynamically via a function that receives

[modes: framework, data, declarative]

Can be a string or a partial [`Path`](https://api.reactrouter.com/v7/interfaces/react-router.Path.html):
Can be a string or a partial [`Path`](https://api.reactrouter.com/v8/interfaces/react-router.Path.html):

```tsx
<Link to="/some/path" />
Expand Down
8 changes: 4 additions & 4 deletions docs/api/components/Navigate.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Navigate.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Navigate.html)

A component-based version of [`useNavigate`](../hooks/useNavigate) to use in a
[`React.Component` class](https://react.dev/reference/react/Component) where
Expand All @@ -43,7 +43,7 @@ function Navigate({ to, replace, state, relative }: NavigateProps): null
### relative

How to interpret relative routing in the `to` prop.
See [`RelativeRoutingType`](https://api.reactrouter.com/v7/types/react-router.RelativeRoutingType.html).
See [`RelativeRoutingType`](https://api.reactrouter.com/v8/types/react-router.RelativeRoutingType.html).

### replace

Expand All @@ -52,9 +52,9 @@ stack

### state

State to pass to the new [`Location`](https://api.reactrouter.com/v7/interfaces/react-router.Location.html) to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
State to pass to the new [`Location`](https://api.reactrouter.com/v8/interfaces/react-router.Location.html) to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).

### to

The path to navigate to. This can be a string or a [`Path`](https://api.reactrouter.com/v7/interfaces/react-router.Path.html) object
The path to navigate to. This can be a string or a [`Path`](https://api.reactrouter.com/v8/interfaces/react-router.Path.html) object

2 changes: 1 addition & 1 deletion docs/api/components/Outlet.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Outlet.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Outlet.html)

Renders the matching child route of a parent route or nothing if no child
route matches.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/components/PrefetchPageLinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.PrefetchPageLinks.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.PrefetchPageLinks.html)

Renders [`<link rel=prefetch|modulepreload>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel)
tags for modules and data of another page to enable an instant navigation to
Expand Down
4 changes: 2 additions & 2 deletions docs/api/components/Route.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Route.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Route.html)

Configures an element to render when a pattern matches the current location.
It must be rendered within a [`Routes`](../components/Routes) element. Note that these routes
Expand Down Expand Up @@ -114,7 +114,7 @@ Mutually exclusive with `HydrateFallback`.

### id

The unique identifier for this route (for use with [`DataRouter`](https://api.reactrouter.com/v7/interfaces/react-router.DataRouter.html)s)
The unique identifier for this route (for use with [`DataRouter`](https://api.reactrouter.com/v8/interfaces/react-router.DataRouter.html)s)

### index

Expand Down
4 changes: 2 additions & 2 deletions docs/api/components/Routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Routes.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Routes.html)

Renders a branch of [`<Route>`s](../components/Route) that best matches the current
location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
Expand Down Expand Up @@ -54,5 +54,5 @@ Nested [`Route`](../components/Route) elements

### location

The [`Location`](https://api.reactrouter.com/v7/interfaces/react-router.Location.html) to match against. Defaults to the current location.
The [`Location`](https://api.reactrouter.com/v8/interfaces/react-router.Location.html) to match against. Defaults to the current location.

2 changes: 1 addition & 1 deletion docs/api/components/Scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.Scripts.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.Scripts.html)

Renders the client runtime of your app. It should be rendered inside the
[`<body>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body)
Expand Down
4 changes: 2 additions & 2 deletions docs/api/components/ScrollRestoration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.ScrollRestoration.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.ScrollRestoration.html)

Emulates the browser's scroll restoration on location changes. Apps should only render one of these, right before the [`Scripts`](../components/Scripts) component.

Expand Down Expand Up @@ -65,7 +65,7 @@ function ScrollRestoration({
A function that returns a key to use for scroll restoration. This is useful
for custom scroll restoration logic, such as using only the pathname so
that later navigations to prior paths will restore the scroll. Defaults to
`location.key`. See [`GetScrollRestorationKeyFunction`](https://api.reactrouter.com/v7/interfaces/react-router.GetScrollRestorationKeyFunction.html).
`location.key`. See [`GetScrollRestorationKeyFunction`](https://api.reactrouter.com/v8/interfaces/react-router.GetScrollRestorationKeyFunction.html).

```tsx
<ScrollRestoration
Expand Down
6 changes: 3 additions & 3 deletions docs/api/data-routers/RouterProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/co

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.RouterProvider.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.RouterProvider.html)

Render the UI for the given [`DataRouter`](https://api.reactrouter.com/v7/interfaces/react-router.DataRouter.html). This component should
Render the UI for the given [`DataRouter`](https://api.reactrouter.com/v8/interfaces/react-router.DataRouter.html). This component should
typically be at the top of an app's element tree. The router prop should
be a single router instance created outside of the React tree. Avoid
creating new routers during React renders/re-renders.
Expand Down Expand Up @@ -88,7 +88,7 @@ and is only present for render errors.

### router

The [`DataRouter`](https://api.reactrouter.com/v7/interfaces/react-router.DataRouter.html) instance to use for navigation and data fetching. The
The [`DataRouter`](https://api.reactrouter.com/v8/interfaces/react-router.DataRouter.html) instance to use for navigation and data fetching. The
router prop should be a single router instance created outside of the React
tree. Avoid creating new routers during React renders/re-renders.

Expand Down
8 changes: 4 additions & 4 deletions docs/api/data-routers/StaticRouterProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/do

## Summary

[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react-router.StaticRouterProvider.html)
[Reference Documentation ↗](https://api.reactrouter.com/v8/functions/react-router.StaticRouterProvider.html)

A [`DataRouter`](https://api.reactrouter.com/v7/interfaces/react-router.DataRouter.html) that may not navigate to any other [`Location`](https://api.reactrouter.com/v7/interfaces/react-router.Location.html).
A [`DataRouter`](https://api.reactrouter.com/v8/interfaces/react-router.DataRouter.html) that may not navigate to any other [`Location`](https://api.reactrouter.com/v8/interfaces/react-router.Location.html).
This is useful on the server where there is no stateful UI.

```tsx
Expand Down Expand Up @@ -57,7 +57,7 @@ function StaticRouterProvider({

### context

The [`StaticHandlerContext`](https://api.reactrouter.com/v7/interfaces/react-router.StaticHandlerContext.html) returned from [`StaticHandler`](https://api.reactrouter.com/v7/interfaces/react-router.StaticHandler.html)'s
The [`StaticHandlerContext`](https://api.reactrouter.com/v8/interfaces/react-router.StaticHandlerContext.html) returned from [`StaticHandler`](https://api.reactrouter.com/v8/interfaces/react-router.StaticHandler.html)'s
`query`

### hydrate
Expand All @@ -72,5 +72,5 @@ tag

### router

The static [`DataRouter`](https://api.reactrouter.com/v7/interfaces/react-router.DataRouter.html) from [`createStaticRouter`](../data-routers/createStaticRouter)
The static [`DataRouter`](https://api.reactrouter.com/v8/interfaces/react-router.DataRouter.html) from [`createStaticRouter`](../data-routers/createStaticRouter)

Loading