1.0.1 • Published 3 years ago

smallfire v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

SmallFire

SmallFire is a Javascript client for accessing Firestore and Firebase realtime databases. It is a much smaller replacement for the the basic functionality of the official Firebase SDK libraries. Compare sizes below:

LibraryFirebase SDKSmallFire
Firebase core7 KB
Auth56 KB0.7 KB
Firestore90 KB2.9 KB
Firebase RTDB51 KB1.0 KB
Full Library204 KB3.9 KB

There are three library modules that can be loaded separately: auth, firestore, and firebase. Or, you can load the combined bundle: smallfire.

The auth module supports only email/password authentication and is only necessary when dealing with non-public data.

Firebase SDK 9 Beta Note

Google has recently released Firebase SDK 9 Beta, which uses a modular approach that has the potential to reduce the size of the SDK. It's difficult to measure the size of the SDK with this version, but our initial testing indicates that when loading the three modules auth, firestore, and firebase, the overal SDK is still above 100 KB.

Firestore Features

These features are supported with the firestore module for the Firestore database: Feature | Description ------------ | ------------- get | get a single document list | list some or all documents in a collection set | replace the value of a document or create a new one update | update fields in a document delete | delete a document query | get documents based on a query listen | get a document and listen for realtime updates

Firebase Realtime Database Features

These features are supported with the firebase module for the Firebase realtime database:

FeatureDescription
getread data
setwrite data replacing existing data
updatewrite data merging with existing data
pushadd to list with a unique key
deletedelete data
listenread data and get realtime updates

Installation

Script Tag

The simplest way to add SmallFire to your web app is to add the following script tag to your <head> or <body> section:

<script src="https://unpkg.com/smallfire/smallfire.js"></script>

You can also add modules individually:

<script src="https://unpkg.com/smallfire/auth.js"></script>
<script src="https://unpkg.com/smallfire/firebase.js"></script>
<script src="https://unpkg.com/smallfire/firestore.js"></script>

Then access the SmallFire functions using the smallfire global variable:

smallfire.auth.currentUser()
smallfire.auth.signIn()
smallfire.auth.signOut()
smallfire.getFirestoreDB()
smallfire.getFirebaseDB()

or

const { auth, getFirestoreDB, getFirebaseDB } = window

Node

If you are using a Node build environment such as with Javascript libraries React or Vue, install SmallFire from NPM:

npm install smallfire

Then import the SmallFire functions:

import { auth, getFirestoreDB, getFirebaseDB } from smallfire/smallfire

or import separately:

import { auth } from smallfire/auth
import { getFirebaseDB } from smallfire/firebase
import { getFirestoreDB } from smallfire/firestore

Documentation

Please see individual module documentation: