I have a single-page-app built with React and Vite. It fetches data entirely on the client-side after it has started up. So there's no server at play other than the server that hosts the static assets.
Until yesterday, the app was use swr
to fetch data, now it's using @tanstack/react-query
instead. Why? Because I'm curious. This blog post attempts to jot down some of the difference and contrasts.
If you want to jump straight to the port diff, look at this commit: https://github.com/peterbe/analytics-peterbecom/pull/47/commits/eac4f873303bfb493320b0b4aa0f5f6ba133001a
Bundle phobia
When @tanstack/react-query
first came out, back in the day when it was called React Query, I looked into it and immediately got scared how large it was. I think they've done some great work to remedy that because it's now not much larger than swr
. Perhaps it's because swr
, since wayback when, has grown too.
When I run npm run build
it spits this out: