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

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • 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.

  • 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.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • react-query

    Discontinued 🤖 Powerful asynchronous state management, server-state utilities and data fetching for TS/JS, React, Solid, Svelte and Vue. [Moved to:]

  • 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