You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This works fine, but it's now impossible to know which [collection] was originally requested (for e.g. highlighting it in the nav).
I've tried to do this with e.g. redirecting to destination: '/product/:product?collection=:collection', but the searchParams aren't passed to either the server or client. Also, this would opt the page out of static mode which defeats the point.
I've also tried looking at window.location manually (because this is the only place still containing the original URL; useParams et al are already returning the rewritten one), but this caused hydration errors.
Proposal
This could be implemented in many ways. One way could be to add a useOriginalPathname() hook.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
Use case: ecommerce store with multiple collections sharing the same products.
store.com/product/[product]
store.com/products/[collection]
store.com/products/[collection]/[product]
The last URL will be rewritten to
store.com/product/[product]
, so we don't have to duplicate the pages during build time:This works fine, but it's now impossible to know which
[collection]
was originally requested (for e.g. highlighting it in the nav).I've tried to do this with e.g. redirecting to
destination: '/product/:product?collection=:collection'
, but thesearchParams
aren't passed to either the server or client. Also, this would opt the page out of static mode which defeats the point.I've also tried looking at
window.location
manually (because this is the only place still containing the original URL;useParams
et al are already returning the rewritten one), but this caused hydration errors.Proposal
This could be implemented in many ways. One way could be to add a
useOriginalPathname()
hook.Beta Was this translation helpful? Give feedback.
All reactions