For the last few months, I have been working on a NextJS application. It seems that every week it gets bigger and bigger. The application uses axios to make API calls and unstated-next as a state solution. There are quite a few API calls, and we don’t want our users to experience too many loading screens. So, we stored the result of our axios calls in our unstated stores.
But we ran into a problem. The stores themselves are getting more and more complicated. Some pages rely on several API calls, and some API calls rely on the results of other API calls. As the days turned into weeks, and the weeks into months, our unstated stores became more and more unwieldy. We started to encounter strange bugs, as our homemade caching logic struggled to deal with rare edge cases.
So we thought to ourselves, there must be a better way.
And there is. It’s even made by Vercel — the creators of NextJS.