Next.js Discord

Discord Forum

searchParams is always empty?

Answered
Oriental posted this in #help-forum
Open in Discord
OrientalOP
hey guys! i started an app with next 14 a while ago and never really used the server components back then! so the app was fully built doing client side stuff in pages and below! we never user the searchParams from the Page, now we are trying to get the searchParams from the Page Page = ({ params, searchParams}) => {} but they always are empty even tho the page is a server component, has anyone come to a similar situation?

my next version: "next": "^14.1.4"
Answered by Oriental
im doing NextResponse.rewrite() and not setting the params from the incoming request
View full answer

23 Replies

I think the issue is this page is being statucly rendered, add export cont revalidate = 0 to force dynamic... Its meant to pick up automaticly that it's using search Params but ig not here
OrientalOP
still with export const revalidate = 0 i don't get the searchParams :/
Hmm
Can you try to get the vas like docs suggest maybe (I don't think it's going to work, but just to be as close as possible)
OrientalOP
sure things! let me add it like that!
sadly, no luck!
Uhhhhhhh
I thought that it was caching breaking it, but idk
Like you adding new Date().toLocalString() in json.stringify to check if it's dynamic (and then refreshing multiple times)
OrientalOP
let me try that
im just reinstalling deps
Also when you say search Params you mean ?foo=bar right
OrientalOP
yessiir!
it is updating the date everytime i refresh
:S
😮
And like this page isn't client right ("use client")
If it was, you should just try useSearchParams
OrientalOP
it's my middleware!
OrientalOP
im doing NextResponse.rewrite() and not setting the params from the incoming request
Answer
OrientalOP
🤦‍♂️
ty for the help man!
@Oriental ty for the help man!
Hahaha no problem, that's a funny issue ngl