unable to access useSearchParams
Unanswered
Naeemgg posted this in #help-forum
NaeemggOP
I'm trying to access page params, my page contains just one client component and all other server components. the page is server side and I'm trying to access it with the only client component. The problem is I'm getting nothing with it.
but if I make whole page
<ServerComponent/>
<ServerComponent/>
<ServerComponent/>
<ServerComponent/>
<clientComponent/>"use client"
import {useSearchParams} from "next/navigation"
const clientComponent = ()=>{
const search = useSearchParams()
const data = search.get("data")
return(<h1>{data}</h1>)}but if I make whole page
use client its working fine3 Replies
useSearchParams is working fine for me, what is the value of search.get("data")?If your url looks like
/page?data=hello, you should be able to receive the data search param with no problemNaeemggOP
yep its exactly like that, more precise
/login?data=role&id=randomUserID&email=user@email.comthis is the exact data I'm willing to get