4 ms·
Next.js teamed with SWR[1] means I could totally remove redux from my app [1] https://swr.now.sh/ https://swr.now.sh/
by cjr 6y ago
Next.js teamed with SWR[1] means I could totally remove redux from my app
[1] https://swr.now.sh/ https://swr.now.sh/
- Rauchg 6y agoAwesome! This is how we use Next.js at Vercel. For those interested, I recently put together these slides https://jamstack-toronto.now.sh/ https://jamstack-toronto.now.sh/ for Jamstack Toronto that goes more in-depth into this. tl;DR: static pages for landing pages, static site generation for content like our blog, static dashboard with SWR against our REST API. Video should be out soon!
- cjr 6y agoCool, do the slides work on mobile?!
- searchableguy 6y agoWhat does that have to do with redux? How does it replace a client side state management solution?
- hesarenu 6y agoI have used react-query which does the same thing. The server responses can be cached like a redux store. The same query can then be reused elsewhere. You have setting to not cache at all, cache for some time or cache infinity. I have used it on redux project and replaced many with react-query. It does feel better for server data. Not much boilerplate.
- cjr 6y agoDepends on your approach but for me most state in redux was remote data which SWR now caches for me. Other shared local state, such as which project a user is currently viewing, just goes into react context. This removed so much boilerplate for me, adding new calls to the backend is now much simpler.
- pspeter3 6y agoWhy SWR as opposed to React Query?
- b34r 6y agoIt’s made by Vercel, probably.
- cjr 6y agoYep
- makeee 6y agoThey're both awesome and I think have borrowed ideas from each-other. I went with React Query because I like the query key format (object instead of a string with SWR). https://github.com/tannerlinsley/react-query#query-keys https://github.com/tannerlinsley/react-query#query-keys
- tiborsaas 6y agoSince I started to combine React context + useReducer, I never felt the need to set up a Redux config. It's much simple with the same power.