Skip to main content
NextRequest extends the native Web Request API with additional convenience methods for use in Middleware and Route Handlers.
middleware.ts

cookies

Read or mutate the cookies on the incoming request.
{ name: string; value: string } | undefined
Returns the first cookie with the given name, or undefined if not found.
{ name: string; value: string }[]
Returns all cookies with the given name, or all cookies if no name is provided.
void
Sets a cookie on the request.
boolean
Deletes the cookie with the given name. Returns true if deleted, false otherwise.
boolean
Returns true if the cookie exists.
void
Removes all cookies from the request.

nextUrl

Extends the native URL API with Next.js-specific properties.

Available properties

The internationalization properties available in the Pages Router (locale, locales, defaultLocale, domainLocale) are not available in the App Router. Use the App Router internationalization guide instead.

Inherited from Request

NextRequest inherits all properties and methods from the native Request API, including:
  • method — HTTP method (e.g. 'GET', 'POST')
  • url — The full request URL as a string
  • headers — A read-only Headers object
  • body — The request body as a ReadableStream
  • json(), text(), arrayBuffer(), formData() — Body parsing methods

Example

middleware.ts

Version history