Docs Hub

🇮🇷
iran mirrors
LaravelLaravelLivewireLivewireAlpine.jsAlpine.jsNext.jsNext.jsVue.jsVue.jsZustandZustandNuxt.jsNuxt.jsFilamentFilament
BootstrapBootstrap
Nest.jsNest.js
ReactReact
Vite.jsVite.js
Tailwind CSSTailwind CSS

© 2026 Juza66 and Arash Fadaee

Docs Hub

🇮🇷 iran mirrors
AfterCacheLifeCacheTagCatchErrorConnectionCookiesDraft ModeFetchForbiddenGenerate Image MetadataGenerate MetadataGenerate SitemapsGenerate Static ParamsGenerate ViewportHeadersImage ResponseOverviewNext RequestNext ResponseNot FoundPermanentRedirectRedirectRefreshRevalidatePathRevalidateTagUnauthorizedUnstable CacheUnstable NoStoreUnstable RethrowUpdateTagUse Link StatusUse ParamsUse PathnameUse Report Web VitalsUse RouterUse Search ParamsUse Selected Layout SegmentUse Selected Layout SegmentsUserAgent
EdgeTurbopackOverview
GlossaryOverview
Overview
Docs Hub
The content of this doc is shared between the app and pages router. You can use the Content component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component.

NextRequest extends the Web Request API with additional convenience methods.

cookies

Read or mutate the Set-Cookie header of the request.

set(name, value)

Given a name, set a cookie with the given value on the request.

ts
// Given incoming request /home
// Set a cookie to hide the banner
// request will have a `Set-Cookie:show-banner=false;path=/home` header
request.cookies.set('show-banner', 'false')

get(name)

Given a cookie name, return the value of the cookie. If the cookie is not found, undefined is returned. If multiple cookies are found, the first one is returned.

ts
// Given incoming request /home
// { name: 'show-banner', value: 'false', Path: '/home' }
request.cookies.get('show-banner')

getAll()

Given a cookie name, return the values of the cookie. If no name is given, return all cookies on the request.

ts
// Given incoming request /home
// [
//   { name: 'experiments', value: 'new-pricing-page', Path: '/home' },
//   { name: 'experiments', value: 'winter-launch', Path: '/home' },
// ]
request.cookies.getAll('experiments')
// Alternatively, get all cookies for the request
request.cookies.getAll()

delete(name)

Given a cookie name, delete the cookie from the request.

ts
// Returns true for deleted, false is nothing is deleted
request.cookies.delete('experiments')

has(name)

Given a cookie name, return true if the cookie exists on the request.

ts
// Returns true if cookie exists, false if it does not
request.cookies.has('experiments')

clear()

Remove all cookies from the request.

ts
request.cookies.clear()

nextUrl

Extends the native URL API with additional convenience methods, including Next.js specific properties.

ts
// Given a request to /home, pathname is /home
request.nextUrl.pathname
// Given a request to /home?name=lee, searchParams is { 'name': 'lee' }
request.nextUrl.searchParams

The following options are available:

PropertyTypeDescription
basePathstringThe base path of the URL.
- defaultLocalestringThe default locale within a domain.
- domainstringThe domain associated with a specific locale.
urlURLThe URL object.
PropertyTypeDescription
basePathstringThe base path of the URL.
pathnamestringThe pathname of the URL.
searchParamsObjectThe search parameters of the URL.
Note: The internationalization properties from the Pages Router are not available for usage in the App Router. Learn more about internationalization with the App Router.

Version History

VersionChanges
v15.0.0ip and geo removed.