Next.js Discord

Discord Forum

searchParams in server returning empty object4

Unanswered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Dwarf CrocodileOP
It's been many days and I can't make searchParams work.

I've a page
export default async function EmailVerification({searchParams}) {
    const q = await searchParams
    console.log(q, '<<');
}


But it's return empty object and here's console log
 ✓ Starting...
 ✓ Compiled in 475ms
 ✓ Ready in 1629ms
 ○ Compiling /auth/verify ...
 ✓ Compiled /auth/verify in 3.2s
{} <<
 GET /auth/verify?x=e 200 in 8125ms


You can there's ?x=e param for testing

8 Replies

Dwarf CrocodileOP
This is page
can you make a minimal reproduction repository?
@joulev only the page component gets the searchParams prop. not all server components
Dwarf CrocodileOP
My dir m structure
Dwarf CrocodileOP
Ok I can confirm when I did again it worked I think it's happening because I've dynamic route at root level this might be the cause

My app dir structure
[slug]
auth/verify
page.jsx
layout.jsx
hmm no it shouldn't be related though. it's not supposed to break
that's why i asked you to create a minimal reproduction repository
without which it's impossible to guess since if i make a repro right now it will 100% work