-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router.query is empty on subsequent client navigation events #9473
Comments
Hi, for the |
Oh, that would explain the behavior we are seeing 👍 We were effectively doing:
|
Hi, I used your solution and it works when i'm listening to the query change in my hook but it doesn't seem to be parsed within router events (routeChangeComplete) |
@ijjk thank you, it helped me. |
Is there an example of how this would work with |
So:
|
@timneutkens If you path first parameter as a full path it will make a hard refresh instead of client-side update, which goes around the issue but not necessarily fixing it. Example I have is in line with docs, with dynamic paths:
|
Works in the same way as the earlier reply:
|
Aaaah, |
|
I believe this is a relevant issue #16019 |
I don't think this is an issue anymore, our docs have been updated and we added more clear examples for the usage of next/link. For client side navigations you have to provide the
If any of the above behaviors doesn't match what you currently have on your application (or our docs do a bad job) feel free to comment it out again with a reproduction and I'll re open the issue. Thank you. |
i think the docs could maybe add some clarification to here. i've written down my understanding of this in this discussion |
Many confusion, still existing. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
Using Next 9's routing solution for a Universal App, "router.query" for post-SSR client-side navigation is never populated even if
asPath
contains a query string for any of the followingrouter access methods:
To Reproduce
Perform an initial navigation to
/search?term=hello
, the server rendered page's router information contains a populated "query":Then navigate to the same pathname, with a different query string:
/search?term=bye
. At this point Router empties "query", but has the correct newasPath
:Expected behavior
For the client side navigation to a route with specified query parameters such as
/search?term=bye
,router.query
contains the parsed query string.If this is not expected, it would be helpful to better document this behavior and the correct approach on the client. I would prefer to always access routing information off of the available hook / HOC rather than off window on the client to avoid a split-brain solution between the client and the server.
The text was updated successfully, but these errors were encountered: