Apollo or Recoil?

A popular question, “which should I choose, Apollo or React”? Well the answer really depends on your unique use case. But, I’ve taken some time to break down what I feel are the Pros and Cons of each. 


Apollo Client

The first time using AC (Apollo Client) I was incredibly impressed, and this impression has yet to change. As the docs say:

Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Use it to fetch, cache, and modify application data, all while automatically updating your UI.”

And they deliver!


The Good Parts

GraphQL: If you’re already using GraphQL it’s a no-brainer. They take care of remote state incredibly well. Initial queries and mutations are relatively easy to get setup.

Fetching & Normalization: They offer a powerful API and with recent versions they improved tree-shaking and implemented React Hooks (game changer). SSR or “server side rendering” in the grand scheme of setup and SSR is easy as well.

Comprehensive: There are a number of ways to Query, Fetch and interact with the data. React Hooks were a blessing and created some clean and powerful abstractions. Testing is included and the docs aren’t half bad.

Other Parts

Requirements: It’s built around (requires) GraphQL, but is that really a bad thing?

Testing: By no means do I mean this testing is bad, just involved. If you are switching from something like Redux, it’s just another set of rules to follow.


RecoilJS

Do we really need “another” state management solution? That is the question I asked myself. However after watching the overview video ideas began to flow and a growing appreciation was seeded.


The Good Parts

Performance: For highly interactive UI’s this is a no brainer. The “atoms” as they are referred to are incredibly powerful and a breeze to setup. For client-side state they simply blog Apollo Client (3.0 included) out of the water.

Setup: Adding RecoilJS to an application is painless, just add the “RecoilRoot” and start to build out the atoms, selectors and whatever else you require you’re off to the races.

Other Parts

Honestly I don’t have any gripes. It’s worth noting that it’s still “experimental” but I’d love to see this approach brought into React Core 🤞.


Conclusion

If you have a complex, richly interactive user-interface and deal with a fair amount of “client state” then Recoil is the way to go. 

If data fetching is core to your application and you can get away with setting up a few contexts then Apollo Client + GraphQL for the win. 

Lastly, maybe you have some wiggle room in terms of overall vendor size. If so, well RecoilJS weighs in at 11.2kb and Apollo Client at 15.6kb. Personally, I’ve taken each of the 3 approaches above. 

Made with in San Diego, CA.