Capítulo 380 de 456
NextRequest extends the Web Request API with convenience methods for cookies and URL parsing, used primarily inside Proxy.
request.cookies: set(name, value), get(name), getAll(name?), delete(name), has(name), clear() — manipulates the request's Cookie header.request.nextUrl: extends native URL with basePath, buildId, defaultLocale, domainLocale (defaultLocale, domain, http), locales, locale, url.// Given incoming request /home
request.cookies.set('show-banner', 'false')
Set-Cookie header).// 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
nextUrl.nextUrl property | Type | Description |
|---|---|---|
basePath | string | configured base path |
buildId | string | undefined | build identifier |
defaultLocale | string | undefined | i18n default locale |
locales | string[] | undefined | supported locales |
locale | string | undefined | active locale |
url | URL | underlying URL object |
ip/geo properties: removed in v15.0.0.NextRequest is primarily used inside Proxy (proxy.js) function signatures.get/getAll/set/delete/has/clear.nextUrl adds Next.js-specific routing/i18n context on top of the standard URL.NextRequest as its first function parameter.