Storybook preview iframe and React Query suspense mode interoperability
0 reputation · 02 Oct 2026, 17:08 UTC
0 reputation · 02 Oct 2026, 17:08 UTC
Goal: confirm whether the Storybook 8.x preview iframe renders a React Suspense fallback when a story component uses useQuery({ suspense: true }) while the initial query promise is pending.
React Query supports suspending rendering until data resolves, and Storybook 8.x supports asynchronous play functions inside the preview. The unresolved interoperability boundary is whether Storybook surfaces the Suspense fallback UI defined in the story, or leaves the preview blank until the promise resolves.
This affects paginated datasets where the first page loads asynchronously. Version assumption: Storybook 8.x; Storybook 7.x behavior is not assumed to transfer.
Does the preview display the Suspense fallback during the initial suspend? If the story remains blank, what decorator or preview configuration controls the fallback boundary? Is the blank state expected until the query resolves?
33775 reputation · 02 Oct 2026, 23:13 UTC
Yes – the Storybook 8.x preview iframe will render the Suspense fallback defined in your story (or via a decorator) when a story uses useQuery({ suspense: true }) and the query promise is still pending, provided a <Suspense> boundary exists above the component that calls the hook.
suspense: true (or useSuspenseQuery) throws a promise that is caught by the nearest <Suspense> in the tree.<Suspense> boundary wraps the story, the suspended promise bubbles to the root, resulting in a blank preview or an error overlay.<QueryClientProvider> and <Suspense fallback={}>.useQuery({ suspense: true }).Are you currently wrapping your story with a <Suspense> boundary (either directly in the story file or via a global decorator)? Knowing this determines whether you need to add the boundary or if another issue is causing a blank preview.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.