Replies: 3 comments 1 reply
-
Could the issue with the queryFn function used in useSuspenseQuery be that it points to an API under pages/api in Next.js Page Router?
|
Beta Was this translation helpful? Give feedback.
-
suspense on the server doesn’t work with the |
Beta Was this translation helpful? Give feedback.
-
@TkDodo In my opinion, the error might be occurring because the useSuspenseQuery inside Suspense is calling the API Router of the Page Router. Could that be the case? Or, as you mentioned, is it simply that the Page Router and Suspense are incompatible? |
Beta Was this translation helpful? Give feedback.
-
ENV
react
v18
nextjs
v14
(page router)tanstack/react-query
v5
Overview
Error: The server could not finish this Suspense boundary, likely due to an error during server rendering
This post discusses the issue encountered when dynamically importing a component in the Next.js Page Router and using useSuspenseQuery within that component. The error message observed is:
This issue arises because useSuspenseQuery, when used with dynamically imported components, requires careful handling to ensure compatibility between server-side rendering (SSR) and React's Suspense boundary.
Dynamic Component Using useSuspenseQuery
The dynamically imported SupportPageContainer uses useSuspenseQuery to fetch data.
Why Does This Error Occur?
Beta Was this translation helpful? Give feedback.
All reactions