Skip to content

How to push entries to browser history on button click only? #816

Answered by franky47
wasimsandhu asked this question in Q&A
Discussion options

You must be logged in to vote

A combination of things to try:

  • The shallow: false option in useQueryState to update the server whenever the num search param changes (that would take care of the back button giving you the right data)
  • Using an uncontrolled number input, that reads its defaultValue from useQueryState, but URL updates only happen when clicking the button (the serializer in nuqs might help with generating a link from the input's internal value).

If you are on Next.js 14, be aware that there is a client cache that causes RSCs to be cached client-side, meaning if going back to a URL that previously fetched data, it won't invalidate/re-render server side unless this cache is cleared or disabled.
https://next…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wasimsandhu
Comment options

Answer selected by wasimsandhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants