Unable to get Search Params in Route Handlers #50536
Unanswered
nsylke
asked this question in
App Router
Replies: 2 comments
-
You have two options: Native: export async function GET(request: Request) {
console.log(new URL(request.url).searchParams.get("foo"));
return new Response("Hello World");
} And with NextRequest: export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
const slug = searchParams.get("slug");
console.log("Processing slug", { slug });
return new Response("Hello World");
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here is what you need to do:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was looking around the docs to try and find a way to get the search params (e.g.
?v=1
) inside of a route handler. I am currently deconstructingreq.url
to receive the search params, is this the only way?Beta Was this translation helpful? Give feedback.
All reactions