Functions
NextRequest
NextRequest extends Request with Next.js URL and incoming-cookie helpers. Import the type from next/server. Incoming query and cookie values still need validation; never use them as verified session identity. Source: https://nextjs.org/docs/app/api-reference/file-conventions/route. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
import { NextRequest } from "next/server";Working Example
Example Snippetnextjs
import type {NextRequest} from 'next/server';export function GET(request:NextRequest){return Response.json({path:request.nextUrl.pathname});}