generateMetadata should not block a route with Suspense
#62888
Replies: 3 comments 4 replies
-
|
@michaelschufi have you any sugestion on How to avoid It? Im thinking on using react-helmet. |
Beta Was this translation helpful? Give feedback.
-
|
I came here looking for a solution to the exact same problem: if I use "generateMetadata" it simply blocks rendering until the entire page has loaded and then renders the page - no suspense, or loading component displays despite them being in the path. Meaning that on a slow query my users stare at a frozen screen wondering if anything is happening. I understand why it happens, the dynamic metadata needs to get populated before anything is sent to the browser. Would be nice if there was some workaround anyone could think of. |
Beta Was this translation helpful? Give feedback.
-
|
I use suspens, around a sub component and it works. Not the whole page |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Adding a
generateMetadatato an intercepting route, completely blocks the whole rendering of the route.This means that we cannot show, e.g. a modal, with a skeleton while loading the content inside a
Suspenseboundary. Which makes for a worse user experience, since the title of the browser tab changing is secondary compared to showing immediate feedback after a click.I suggest making an exception to the
generateMetadata's blocking behaviour for intercepting routes, or making it configurable.Edit: Actually, it shouldn't block in pages that load the content in a suspense as well. Because it kind of defeats the purpose of fetching the content while e.g. the layout is rendering already.
Beta Was this translation helpful? Give feedback.
All reactions