Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export async function GET(_req: NextRequest, ctx: RouteContext<'/users/[id]'>) {

Middleware allows you to run code before a request is completed. Then, based on the incoming request, you can modify the response by rewriting, redirecting, modifying the request or response headers, or responding directly.

> **Note**: The `middleware` file convention is deprecated and has been renamed to [`proxy`](/docs/app/api-reference/file-conventions/proxy). Please use `proxy.js|ts` instead of `middleware.js|ts`. The `middleware` convention will be removed in the future versions of Next.js.

### Use cases

Some common scenarios where Middleware is effective include:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ related:

The `middleware.js|ts` file is used to write [Middleware](/docs/app/getting-started/route-handlers-and-middleware#middleware) and run code on the server before a request is completed. Then, based on the incoming request, you can modify the response by rewriting, redirecting, modifying the request or response headers, or responding directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clone this file so the new API name is discoverable instead and not under middleware URL.


> **Note**: The `middleware` file convention is deprecated and has been renamed to [`proxy`](/docs/app/api-reference/file-conventions/proxy). Please use `proxy.js|ts` instead of `middleware.js|ts`. The `middleware` convention will be removed in the future versions of Next.js.

Middleware executes before routes are rendered. It's particularly useful for implementing custom server-side logic like authentication, logging, or handling redirects.

> **Good to know**:
Expand Down Expand Up @@ -688,6 +690,7 @@ Learn how to [configure Middleware](/docs/app/guides/self-hosting#middleware) wh

| Version | Changes |
| --------- | --------------------------------------------------------------------------------------------- |
| `v16.0.0` | Middleware deprecated, renamed to Proxy |
| `v15.5.0` | Middleware can now use the Node.js runtime (stable) |
| `v15.2.0` | Middleware can now use the Node.js runtime (experimental) |
| `v13.1.0` | Advanced Middleware flags added |
Expand Down
Loading
Loading