Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cleaning required but here's the two angular stone:
The first and most important is to do the "initial" replaceHistory with the router always. Without that, NextJS internal state (observable with
window.history.state
) is botched up and missing searchParameters, which makes everything go haywire way later down the road.It's quite sneaky because the thing causing issue at the very end was at the very beginning (reg. execution order at least).
The caveat that comes with that is that all landing takes a double query.
It would have been the least worse evil IMO.
However, I wanted to squash it down, and so I unwrapped some new toys: The Cache.
I won't go on a spiel about caches with NextJS, it's a bit convulated. What's important to know is that essentially for what we want, we needed a Data Cache, and since Next14, well it's available (unstable, but available. It often fails in next dev, didn't manage to make it fail with next prod)
The flow is as such:
router.replace()
with the search params.