How do you handle fetching data from REST API and caching?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/SwiftUI

Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - A developer's best friend. Try free for 14-days
  • Nanos - Run Linux Software Faster and Safer than Linux with Unikernels
  • GitHub repo Pigeon

    Async state management for SwiftUI (and UIKit) 🐦 (by fmo91)

    Pigeon is a library that comes pretty close to what I had in mind as it is even inspired by React Query, however, it still seems a bit unfinished and the project might even be more or less dead already, so I'm a bit worried building my app around it.

  • GitHub repo Kingfisher

    A lightweight, pure-Swift library for downloading and caching images from the web.

    Image loading, displaying and caching is a very similar problem and it seems there are some pretty good solutions available (e.g. Kingfisher), so I'm quite surprised that I'm struggling to find a popular/reliable/stable solution for (REST) API data.

  • Appwrite

    Appwrite - The Open Source Firebase alternative introduces iOS support. Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!

  • GitHub repo react-query

    ⚛️ Hooks for fetching, caching and updating asynchronous data in React

    In a React (JavaScript) environment I found React Query does a fantastic job. Basically, you tell it how to fetch data and it automatically re-renders the component (view) whenever the state changes, e.g. idle, fetching, error, or the actual result data. In addition you can easily define caching behaviour globally or for each query (API endpoint) individually, how long stale data is acceptable etc., plus, data is shared between all views/components that require it. The library abstracts away a lot of common yet pretty hard to manage tasks whilst still being flexible.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts