Files
next.js/test/e2e/app-dir/app-middleware-proxy/app/rsc-cookies/page.js
d7a58203d1 Deprecate middleware and recommend proxy (#84119)
We recommend users avoid relying on Middleware unless no other options
exist. Our goal is to give them APIs with better ergonomics so they can
achieve their goals without Middleware.

The term “middleware” often confuses users with Express.js middleware,
which can encourage misuse. To clarify our direction, we are renaming
the file convention to “proxy.” This highlights that we are moving away
from Middleware, breaking down its overloaded features, and making the
Proxy clear in its purpose.

`proxy.js` should be a drop-in replacement for `middleware.js` for its
features, but ONE thing:

```diff
- export function middleware
+ export function proxy
```

Codemod: https://github.com/vercel/next.js/pull/84127

---------

Co-authored-by: Benjamin Woodruff <[email protected]>
2025-10-09 04:00:53 +02:00

27 lines
764 B
JavaScript

import { cookies } from 'next/headers'
import Link from 'next/link'
import { Form } from './form'
export default async function Page() {
const rscCookie1 = (await cookies()).get('rsc-cookie-value-1')?.value
const rscCookie2 = (await cookies()).get('rsc-cookie-value-2')?.value
return (
<div>
<p id="rsc-cookie-1">Cookie 1: {rscCookie1}</p>
<p id="rsc-cookie-2">Cookie 2: {rscCookie2}</p>
<p id="total-cookies">Total Cookie Length: {(await cookies()).size}</p>
<Link href="/rsc-cookies-delete" prefetch={false}>
To Delete Cookies Route
</Link>
<Form
action={async () => {
'use server'
return (await cookies()).get('rsc-cookie-value-1')?.value
}}
/>
</div>
)
}