Nextjs 14 App Router fetch data as the searchParams change
I use App router in Nextjs 14.
I'm having a problem fetching my data from page component as I change the searchParams in client component using params.set and params.delete. It is causing Hydration error.
Can somebody guide me?
1 Reply
the way I did it in one of my apps was using router.push
for your page using params make sure you're taking searchParams from the page props like this:
and in your client component:
not sure if this is the correct way to work with searchParams in app router but it worked fine for me