- ๐ค Just the right amount of abstraction.
- โ๏ธ Built natively with React hooks to manage state.
- ๐น๏ธ Minimal boilerplate โ take back full control where you need it.
- ๐ Strong integration of TypeScript types for functions, data, and more.
- โ๏ธ Simplified server logic for Callables, batch execution, and more.
- ๐ฑ High consistency between
reactandreact-native. - โ
Reliance on well adopted libraries:
- ๐ฅ
react-firebase-hooksfor web. - โ๏ธ
react-native-firebasefor native.
- ๐ฅ
1 โ Define Realtime Connections
Firebridge mixes the power of Firebaseโs Cloud Firestore and React hooks to help you express realtime platform logic in a very simple format. We give you a simple format for defining typed realtime connections to Cloud Firestore.This format might look familiar. Under the hood on
@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.
2 โ Cloud Callables
Sometimes we need to run an operation on the server before a write can occur. Letโs say when a user posts a review, we want to make sure that the review doesnโt contain any explicit content. First, we can create a utility to save reviews to the database. Weโll use thefirestoreSet 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.
Cloud
Cloud
useCallable hook. We can even include the same type definitions so that the request and response are typed correctly.