You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/community/api-development-strategy.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: API Development Strategy
6
6
7
7
React Router is foundational to your application. We want to make sure that upgrading to new major versions is as smooth as possible while still allowing us to adjust and enhance the behavior and API as the React ecosystem advances.
8
8
9
-
Our strategy and motivations are discussed in more detail in our [Future Flags][future-flags-blog-post] blog post.
9
+
Our strategy and motivations are discussed in more detail in our [Future Flags][future-flags-blog-post] blog post and our [Open Governance Model][governance].
10
10
11
11
## Future Flags
12
12
@@ -36,10 +36,9 @@ To learn about current unstable flags, keep an eye on the [CHANGELOG](../start/c
36
36
37
37
### Example New Feature Flow
38
38
39
-
The decision flow for a new feature looks something like this (note this diagram is in relation to Remix v1/v2 but applies to React Router v6/v7 as well):
39
+
The decision flow for a new feature looks something like this:
40
40
41
-
![Flowchart of the decision process for how to introduce a new feature][feature-flowchart]
41
+
<imgwidth="400"src="https://reactrouter.com/_docs/feature-flowchart.png"alt="Flowchart of the decision process for how to introduce a new feature" />
Copy file name to clipboardExpand all lines: docs/start/data/route-object.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,20 +54,20 @@ function MyRouteComponent() {
54
54
}
55
55
```
56
56
57
-
## `unstable_middleware`
57
+
## `middleware`
58
58
59
59
Route [middleware][middleware] runs sequentially before and after navigations. This gives you a singular place to do things like logging and authentication. The `next` function continues down the chain, and on the leaf route the `next` function executes the loaders/actions for the navigation.
Here's an example middleware to check for logged in users and set the user in
@@ -125,19 +125,19 @@ async function authMiddleware ({
125
125
context.set(userContext, user);
126
126
};
127
127
128
-
exportconstunstable_middleware= [authMiddleware];
128
+
exportconstmiddleware= [authMiddleware];
129
129
```
130
130
131
131
<docs-warning>Please make sure you understand [when middleware runs][when-middleware-runs] to make sure your application will behave the way you intend when adding middleware to your routes.</docs-warning>
This is the client-side equivalent of `unstable_middleware` and runs in the browser during client navigations. The only difference from server middleware is that client middleware doesn't return Responses because they're not wrapping an HTTP request on the server.
140
+
This is the client-side equivalent of `middleware` and runs in the browser during client navigations. The only difference from server middleware is that client middleware doesn't return Responses because they're not wrapping an HTTP request on the server.
141
141
142
142
Here's an example middleware to log requests on the client:
143
143
@@ -158,9 +158,7 @@ async function loggingMiddleware(
Copy file name to clipboardExpand all lines: docs/upgrading/future.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,43 @@ This guide walks you through the process of adopting future flags in your React
9
9
10
10
We highly recommend you make a commit after each step and ship it instead of doing everything all at once. Most flags can be adopted in any order, with exceptions noted below.
11
11
12
-
<docs-warning>**There are no current future flags in React Router v7**</docs-warning>
12
+
## Update to latest v7.x
13
+
14
+
First update to the latest minor version of v7.x to have the latest future flags. You may see a number of deprecation warnings as you upgrade, which we'll cover below.
Middleware allows you to run code before and after the [`Response`][Response] generation for the matched path. This enables common patterns like authentication, logging, error handling, and data preprocessing in a reusable way. Please see the [docs](../how-to/middleware) for more information.
If you're using `react-router-serve`, then you should not need to make any updates to your code.
48
+
49
+
You should only need to update your code if you are using the `context` parameter in `loader` and `action` functions. This only applies if you have a custom server with a `getLoadContext` function. Please see the docs on the middleware [`getLoadContext` changes](../how-to/middleware#changes-to-getloadcontextapploadcontext) and the instructions to [migrate to the new API](../how-to/middleware#migration-from-apploadcontext).
0 commit comments