NextRequest
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.
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.
getAll()
Given a cookie name, return the values of the cookie. If no name is given, return all cookies on the request.
delete(name)
Given a cookie name, delete the cookie from the request.
has(name)
Given a cookie name, return true
if the cookie exists on the request.
clear()
Remove the Set-Cookie
header from the request.
nextUrl
Extends the native URL
API with additional convenience methods, including Next.js specific properties.
Version History
Version | Changes |
---|---|
v13.0.0 | useSearchParams introduced. |