Firebridge is a set of patterns that will help you build powerful and consistent developer experiences with Firebase on React Web and Native.
react
and react-native
.react-firebase-hooks
for web.react-native-firebase
for native.@firebridge/web
, we’re
using
react-firebase-hooks
with a few small extensions on the syntax. We’ve also implemented the same
hooks for @firebridge/native
.useDocument
has a dependency array similar to useEffect
. By providing a value, we can ensure the ref is updated when the value changes. This is useful for when we want to maintain a realtime connection to a document that depends on a value that changes over time.
It’s also common to include the user’s ID as part of the path to a document. This makes writing Firestore security rules much easier. In this case, the ref can be provided as a function which accepts the current user’s ID as the first argument.
timeCreated
in the documents. This makes sorting by creation date very easy.
firestoreSet
utility from @firebridge/cloud
to create a function that will save the review to the database. We’ll ask it to include metadata like a FirestoreTimestamp for the timeCreated
to make querying easy.
useCallable
hook. We can even include the same type definitions so that the request and response are typed correctly.