query: React Query Devtools cannot serialize BigInt type
Describe the bug
One of the models that I am caching with React Query is a BigInt type. Unfortunately, when I try and inspect the data in the devtools explorer, I get an uncaught error: TypeError: Do not know how to serialize a BigInt.
To Reproduce Steps to reproduce the behavior:
- Add an object using a BigInt type to the query cache
- Open the Devtools
- Select the query in the browser to inspect the data
- See the error
Expected behavior I should be able to view properly serialised data in the devtools browser.
Screenshots

Desktop (please complete the following information):
- OS: Pop_OS 21.04
- Browser: Chrome
- Version: 94
Additional context The error can be traced to this line: https://github.com/tannerlinsley/react-query/blob/master/src/devtools/Explorer.tsx#L112. If there’s a reason that the data is being stringified, then hopefully there’s a way to keep doing it, but there are data types which cannot be parsed by JSON.stringify. There may be other options, such as https://github.com/blitz-js/superjson but I understand that would add further complexity.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (2 by maintainers)
Commits related to this issue
- fix: react-query bigint serialization problem https://github.com/TanStack/query/issues/3082 — committed to fijoyapp/fijoy by itsjoeoui 2 years ago
- fix: react-query bigint serialization problem https://github.com/TanStack/query/issues/3082 — committed to fijoyapp/fijoy by itsjoeoui 2 years ago
I’m having the same problem but on
react-query-devtoolswhile using https://wagmi.sh/ library.In some screens when i opened the dev tools it will throw that error.
I had to add this to my
ReactQueryProviderfileso helpful, tu! i ended up adding it my react apps’ entry, main.tsx. this way it applied everywhere which doesn’t seem to hurt anything
if it’s in the QueryKey: pass a custom
queryKeyHashFnif it’s in thedata, it shouldn’t be a problem.🎉 This issue has been resolved in version 3.34.18 🎉
The release is available on:
Your semantic-release bot 📦🚀
Yeah I just dug into the hydration code and the serialisation will all be the purview of Next, so I can just serialise it myself for hydration. I’ll take a look into the dev tools in the new year.
@Ephem I think we decided with this issue:
that its a limitation of hydration to only support json serializable values, right? We have since documented it here:
https://react-query.tanstack.com/reference/hydration#limitations
it’s actually not a concern of hydration / dehydration, because that gives you an
object, but it seems that passing this object to the return value ofgetStaticPropsin nextJs expects it so be json serializable ?