Opinionated Firebase SDK Wrapper

I have a decent Firebase SDK wrapper

It includes firebaseui so you can do social/phone/email logins, as well as the core SDK. It initialises a namespaced apps so that you can have multiple clients running in parallel without clashes (something that would come up in a collaborative environment like Observable otherwise).

It also has an adapter for the realtime databases “listen” we manages tearing down subscriptions and maps a database location to a generator so it works nicely with Observables dataflow when uses as the value of a cell.

There is also a port of some firebase-admin functionality in a different notebook

This allows verifying and minting JWT from Google Service Accounts. Not much use in a users browser but very useful if you run the browser in a privileged environment like Serverless Cells / Endpoint Services / Observable . I built a whole serverless Oauth 2.0 server notebook firebase and observable: Federated IndieAuth Server / Endpoint Services / Observable.

There is also a video and app building demo here Chat application with Firebase on Observable (Twitch) / Tom Larkworthy / Observable

3 Likes

Since I made this, the Firebase SDK has moved on to a modular architecture which is much better for web. Currently the existing Firebase SDK is 1MB! And most of this is Firestore which is often not even used.

Unfortunately most of the code examples for Firebase use module destructure syntax which is not available in Observable:-

import { initializeApp } from 'https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-app.js';

But with some codegen I have been able to wrap each module in a notebook and provide an idiomatic interface to the latest Firebase SDKs, getting us back destructuring syntax

import { initializeApp } from '@tomlarkworthy/firebase-app';

So here we go! Now we can use the latest Firebase SDKs in a relatively un-opinionated way thanks to the Modular Firebase SDK collection