Open ebidrey opened 1 week ago
I've hit this same issue too. It has forced me to change all my page titles to generic static strings so that suspense fallback gets rendered.
I've hit this same issue too. It has forced me to change all my page titles to generic static strings so that suspense fallback gets rendered.
Sadly I can't do that. The site I'm working on has half million different pages and this would broke the SEO dramatically :/
I saw the same applies for new async API for request params or searchParams.
There is an explanation in "generateMetadata" function docs saying:
Next.js will wait for data fetching inside generateMetadata to complete before streaming UI to the client. This guarantees the first part of a streamed response includes tags.
It actually makes sense that page can be streamlined only after all metadata fetching is done.
But on the other hand it goes against this whole "await params" API change which says:
However, not all components depend on request-specific data, so it's unnecessary to wait for the request to render them. Ideally, the server would prepare as much as possible before a request arrives
In that case nothing can be prepared and streamlined to the client in advance when used together with async generateMetadata.
Is there any plan to improve this?
Link to the code that reproduces this issue
https://github.com/ebidrey/suspense-generate-metadata
To Reproduce
To Reproduce
You can run this simple snippet
It is also available in github repo
Current vs. Expected behavior
I expect suspense fallback to be activated immediately when the page request is made and then, the page and the metadata get streamed. Instead, page stucks for the amount of time the request to the api takes, showing nothing up to the request finished, degradating the user experience and not improving SEO in any way.
Provide environment information
Which area(s) are affected? (Select all that apply)
Metadata, Performance
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
Tested in latest canary and stable.