Skip to content
Discussion options

You must be logged in to vote

Have you tried,

request.nextUrl.searchParams

To be more precise:

import { NextRequest } from "next/server";

export async function GET(request: NextRequest) {
  console.log(request.nextUrl.searchParams.get("foo"));
  return new Response("Hello, Next.js!");
}

Which would log bar for this request:

GET http://localhost:3000/api/hello?foo=bar

Replies: 6 comments 17 replies

Comment options

You must be logged in to vote
15 replies
@sajid-munawar
Comment options

@Muneeb-Mohd
Comment options

@jericrealubit
Comment options

@nicope
Comment options

@alsgy2001
Comment options

Answer selected by dapjeongneo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@emporteme
Comment options

Comment options

You must be logged in to vote
1 reply
@IRediTOTO
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet