stale data with router.replace() and searchParams #52012
Unanswered
K1NXZ
asked this question in
App Router
Replies: 1 comment 1 reply
-
@K1NXZ, did you ever resolve this? I'm facing this issue too. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now I am trying to build a page with several filter options and pagination in urlSearchParams. The data that is served, can be manipulated from other sources.
The issue:
The client will always serve stale data when using
router.replace()
or anext/link
component. This can lead to skipping entire pages of data or having the same data on multiple pages of the pagination until the user refreshes it manually (or hard navigation). For now I am using a workaround by making the pagination links a normal<a>
tag which result in hard navigation with refreshed data. Therouter.replace()
issue is worked around with an additional call torouter.refresh()
for now, but sadly it does result in 2 requests being performed instead of just 1.My suggestion would be to combine the calls and have an options parameter for
router.replace()
something like this:which would invalidate the client side cache before actually replacing. This should only perform one request.
same goes for
next/link
.Beta Was this translation helpful? Give feedback.
All reactions