Closed aaronzshey closed 3 days ago
In this case you should create a secondary component that uses it, or provide a loading.tsx
file alongside your page.jsx
, which will automatically wrap the exported page with suspense and use the contents of the loading file as the fallback.
In this case you should create a secondary component that uses it, or provide a
loading.tsx
file alongside yourpage.jsx
, which will automatically wrap the exported page with suspense and use the contents of the loading file as the fallback.
Where can I find this in the documentation? If it isn't there, would it be acceptable for me to add it?
Link to the code that reproduces this issue
https://github.com/aaronzshey/usesearchparams-reproduction/blob/bd514220ce63a6b1b8aeb691711e16245b1ecc70/app/page.tsx#L6
To Reproduce
git clone git@github.com:aaronzshey/usesearchparams-reproduction.git
cd usesearchparams-reproduction
npm install && npm build
Current vs. Expected behavior
According to the current documentation, this error should be solved by wrapping a component using
useSearchParams
inSuspense
tags. However, what do I do when I'm not exporting a component, but just using it for a value? For example, something like this:According to icyJoseph, one could use
document.location.search
. However, this exposes a whole new host of issues, such asdocument
not being found, etc etc.Is there a way to resolve this issue while still using useSearchParams? And if so, can it be added to the documentation?
Provide environment information
Which area(s) are affected? (Select all that apply)
Navigation
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Relevant issue: https://github.com/vercel/next.js/discussions/61654