Open tmaihoff opened 1 year ago
Wrap it in suspense, that should help. It's mentioned in beta docs for useSearchParams.
This bug appears also with usePathname
and Suspense
doesn't help. I can't reproduce it, but I check logs and sometime users see the __next_error__
page instead of correct page
Wrap it in suspense, that should help. It's mentioned in beta docs for useSearchParams.
For me it worked in Next 13.5.5.
i tried to fix with Suspense as in docs but didnt work in Next 14.1.0
same issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Metadata (metadata, generateMetadata, next/head, head.js)
Link to the code that reproduces this issue
https://github.com/tmaihoff/next-metadata-issue
To Reproduce
Reproduction example
This is my layout.tsx
How to break static generation with
useSearchParams
This is my
ClientComponent
breaking the static generation.With the above
ClientComponent
, the generatedindex.html
looks like this. You can see that the<meta>
tags are missing inside<head>
. However they are present in<script>self.__next_f.push([1,'3: ...
How to fix it
Just removing the line
useSearchParams
from theClientComponent
does the trick. Using thisresults in the following
index.html
with statically generated<meta>
tags:Describe the Bug
Just using the
useSearchParams
hook in a client component breaks the static site rendering of the whole app. This can be observed e.g. by the meta tags not being statically generated withnpm run build
. Just removing the hook from the code makes the static generation work.Please check the Reproduction example.
Expected Behavior
useSearchParams
should not affect the static site generation of server components of the app.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1444