Skip to content

Commit 3cef8d8

Browse files
committed
Updated EXAMPLES.md
1 parent 4a9c9e0 commit 3cef8d8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

EXAMPLES.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,3 +2382,30 @@ export async function middleware(request) {
23822382
### Run code after callback
23832383
23842384
Please refer to [onCallback](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#oncallback) for details on how to run code after callback.
2385+
2386+
## Next.js 16 Compatibility
2387+
To support `Next.js 16`, rename your `middleware.ts` file to `proxy.ts`, and rename the exported function from `middleware` to `proxy`.
2388+
All existing examples and helpers (`getSession`, `updateSession`, `getAccessToken`, etc.) will continue to work without any other changes.
2389+
2390+
```diff
2391+
2392+
- // middleware.ts
2393+
- export async function middleware(request: NextRequest) {
2394+
- return auth0.middleware(request);
2395+
- }
2396+
2397+
+ // proxy.ts
2398+
+ export async function proxy(request: Request) {
2399+
+ return auth0.middleware(request);
2400+
+ }
2401+
2402+
```
2403+
> [!NOTE]
2404+
> Next.js 16 still supports the traditional `middleware.ts` file for Edge runtime use-cases,
2405+
but it is now considered deprecated. Future versions of `Next.js` may remove Edge-only middleware,
2406+
so it’s recommended to migrate to `proxy.ts` for long-term compatibility.
2407+
2408+
For more details, see the official Next.js documentation:
2409+
2410+
➡️ [Upgrading to Next 16 Middleware](https://nextjs.org/docs/app/api-reference/file-conventions/proxy#upgrading-to-nextjs-16)
2411+
➡️ [Proxy.ts Conventions](https://nextjs.org/docs/app/api-reference/file-conventions/proxy)

0 commit comments

Comments
 (0)