nandorojo / swr-firestore

Implement Vercel's useSWR for querying Firestore in React/React Native/Expo apps. 👩‍🚒🔥
MIT License
777 stars 65 forks source link

Support for custom ID with new documents / offline support #111

Open myktra opened 3 years ago

myktra commented 3 years ago

Is it possible to enhance the add(data) function returned by the useCollection hook to allow the client/caller to supply their own sufficiently unique/predictable ID for new documents, for example via the nanoid library? Currently this implementation seems to require standard Firestore library/server-generated IDs.

https://github.com/nandorojo/swr-firestore/blob/68844645137dd009b3d8e15d69a85e009bfe3f45/src/hooks/use-swr-collection.ts#L500

Ultimately looking for offline support for new documents as noted in issue #56 and PR #55. This would be a killer feature!!!