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
  • Zigi - Workflow assistant built for devs & their teams
  • Scout APM - Truly a developer’s best friend
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • SonarLint - Clean code begins in your IDE with SonarLint
  • 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.

  • Zigi

    Workflow assistant built for devs & their teams. Automate the mundane part of your day, with live actionable messages for your GitHub & Jira tasks.

  • react-query

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

    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