The client library for LargeMouth BAAS

bower install smallmouth


LargeMouth an open BAAS Build Status

The Client Library for LargeMouth BAAS


Firebase is a Backend As A Service (BAAS) which allows developers to quickly build applications without worrying about the communication layer between the server and client. Firebase is awesome but the backend remains entirely proprietary. LargeMouth / SmallMouth attempt to recreate the Firebase api as an open-source project. Idealy a Firebase app could be easily moved to SmallMouth and vice versa.

LargeMouth is built on top of and NodeJS.


SmallMouth can be installed using the client JavaScript package manager Bower

bower install smallmouth


Creating Resources

Create a new resource just as you would with FireBase, except make the server referenced is a running instance of LargeMouth.

    var chats = new SmallMouth.Resource('http://localhost:3000/chats');

    // If the defaultHost is defined, the following statement is equivalent to the previous.
    SmallMouth.defaultHost = "http://loclahost:3000";
    chats = new SmallMouth.Resource('/chats');

SmallMouth aggressively stores content within local storage on the client. As resources are created and data is saved, initially everything is stored locally before being saved to the server. Because all data is stored locally on the client, SmallMouth can be used as an entirely clientside store (note make sure a modern browser is used). Create a client side data structure by not including a server when instantiating a new resource:

    var chats = new SmallMouth.Resource('/chats');

    chats.on('value', function(snapshot) {

See a more complete example with AngularJS.

SmallMouth in NodeJS

Install SmallMouth via npm: npm install smallmouth

When running in Node, SmallMouth depends upon jsdom, which in turn depends upon contextify. Building contextify requires native building. This should be fine in Linux or MacOS, but requires some extra setup for Windows. See for additional instructions.

    var SmallMouth = require('smallmouth');

    var chats = new SmallMouth.Resource('http://localhost:3000/chats');

    // The API is the same as the browser from here on out, 
    // other than there is no "LocalStorage" implemented

Release notes

  • v0.3.3 - Add .auth method for custom authentication passing a token. LargeMouth must implement a auth method in its manifest file in order for it to resolve. We no longer immediately subscribe (or even connect to LargeMouth) when resources are created, rather we wait till an event is attached or remove, set, child, or update is called.
  • v0.3.2 - Add a default host option allowing declarations not to include the host.
  • v0.3.1 - Add an adapter for communicating with native websockets rather than a wrapper library. Also convenience methods for switching between adapters - SmallMouth.getAvailableAdapters() SmallMouth.setSocketAdapter(SmallMouth.getAvailableAdapters()[0]).
  • v0.3.0 - Implement basic security and the remove method.
  • v0.2.4 - Add a method SmallMouth.Resource.postMessage(type, data) and SmallMouth.postMessage(host, type, data) to send custom messages to the server. See LargeMouth's documentation for how to register custom event listeners.
  • v0.2.3 - Refactor the EventRegistry into a class. For event listener callback functions, the second parameter is now an options object which currently is only passed whether or not the data is from the local or remote registry, egs. {local: true}
  • v0.2.1 - Fix sockjs implementation to queue events to send once the connection is finally made
  • v0.2.0 - Support connecting to multiple backend hosts (create separate data registries for each host). Support multiple types of socket architectures ( and sockjs).
  • v0.1.11 - Support a minimal portion of the Firebase API with the following resource methods: on, off, set, update, remove, push, child, parent, root, name, toString. Support the following snapshot methods: val, child, forEach, hasChild, hasChildren, name, numChildren, ref

Road map

LargeMouth is under active development with the following roadmap. If interested in contributing, please fork the project!

  • Complete the Firebase JavaScript api
  • Build the security layers
  • Implement a database layer for MongoJS and LevelDB (currently the project is entirely in-memory)
  • Build a plugin api
  • Allow for custom defining custom events

Bitdeli Badge