Next.js Discord

Discord Forum

Intercepting routes clears Query Parameters from the route that initiated the request.

Answered
Wesley Janse posted this in #help-forum
Open in Discord
Avatar
I have a product listing page, with pagination that works with Algolia (algolia is still very hook heavy, so mostly 'use client components'), the pagination is query parameter based.

I then have an intercepting route for an out-of-stock modal, so whenever a product is OOS i can open the modal and have full RSC functionality to fetch the user/date etc...

The only issue i'm facing now, is that whenever I open the intercepting route/modal. the query parameter gets cleared so the view behind the modal jumps back to page 0 instead of staying on the active page.

Is there any way to solve this?

What I was thinking of:
- Track the previous value and keep it in a ref
- Detect if an intercepting route is open, then use the previous value. (But I can't find in the docs if/how this is possible).
Answered by Wesley Janse
Found a solution, I will just have to pass the existing query parameters to the new url
View full answer

1 Reply

Avatar
Found a solution, I will just have to pass the existing query parameters to the new url
Answer