// the find
nandorojo/swr-firestore
Implement Vercel's useSWR for querying Firestore in React/React Native/Expo apps. 👩🚒🔥
A React/React Native hook library that wraps Firestore document and collection queries in Vercel's SWR, giving you useDocument/useCollection with caching, revalidation, and optional realtime listeners. It's aimed at teams already using Firestore who want SWR's ergonomics (and shared cache) without hand-rolling their own data layer.
The cross-query cache sync is the actual clever part: updating a document via a collection query re-renders any other component subscribed to that same document by id, which genuinely replaces a chunk of what people reach for Redux to do. Mutation helpers (set/update/add/deleteDocument) write to Firestore and the local SWR cache in one call instead of making you wire that up yourself. Date parsing (parseDates) and automatic snapshot stripping remove two of the most common Firestore boilerplate annoyances (.toDate() calls, non-serializable snapshot objects leaking into state).
Last push was mid-2023 and it's built entirely on the Firebase v8 namespaced SDK — v9's modular SDK isn't supported, it's patched over with a workaround linked from a GitHub comment, which is a bad sign for anyone starting a new project on current Firebase. Single maintainer, no recent releases, and the Expo offline story depends on a separate, equally stale companion package (expo-firestore-offline-persistence) rather than anything built in. The global Fuego singleton (created once outside your component tree) makes it awkward to swap Firestore instances for testing or multi-tenant setups. There's no guidance on how the shared cross-query cache interacts with Firestore security rules — two components running differently-scoped queries against the same document id will both see whichever version last resolved, which could surprise you in an app with row-level permissions.