Error with NextAuth + React-query This Suspense boundary received an update before it finished hydrating #7503
-
EnvironmentSystem: ![]() Reproduction URLhttps://github.com/enyelsequeira/react-query-hydration-issue/tree/next-auth-issue Describe the issueSo I am using react-query with next-auth, however when combined these and using suspense I get an error like the one below, I am trying to use suspense with react query, a very simple example can be found. what I have found
![]() How to reproduceClone Expected behaviorThe expected behavior should be that even when using suspense I should not have that error and that both providers should be able to stay within the same |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hey @balazsorban44 not sure if you have any feedback on this? I mentioned this to the react query and might be because of next-auth, not sure if there are any workarounds TanStack/query#5335 (comment) |
Beta Was this translation helpful? Give feedback.
-
We're having the same issue here, I think. It's preventing us from using the The RQ maintainer mentioned this on TanStack/query#5335 (comment):
I wonder if this will be resolved in #7443? |
Beta Was this translation helpful? Give feedback.
-
@philwolstenholme I just tried NextAuth v5 and the issue still persists. |
Beta Was this translation helpful? Give feedback.
-
Copying my recent answer from Twitter. https://x.com/balazsorban44/status/1811722891915886894 There's no reason to use We could add a guide! Anyone wants to PR? Technically, Auth.js is nothing else than some endpoints that React Query can integrate with itself. SessionProvider is basically just a poorer version of React Query implementation. See the source here https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/react.tsx |
Beta Was this translation helpful? Give feedback.
Copying my recent answer from Twitter.
https://x.com/balazsorban44/status/1811722891915886894
There's no reason to use
SessionProvider
with React Query. In fact, I toyed with an official integration before https://github.com/nextauthjs/react-query, but dropped it as I had no bandwidth to maintain. All you need to do is hook up fetch/api/auth/session
though.We could add a guide! Anyone wants to PR?
Technically, Auth.js is nothing else than some endpoints that React Query can integrate with itself. SessionProvider is basically just a poorer version of React Query implementation.
See the source here https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/react.tsx