Developers have been able to use Firebase in their Node.js projects for many months. Today, we’re formalizing our commitment to Node by publishing Firebase as a packaged module. We haven’t done this until now because our wire protocol was still in flux. This meant that any changes we made could potentially break our developers' apps.
As of today, however, the wire protocol has been tested well enough with real production apps that we are ready to declare it “stable”. This means that we are guaranteeing continued support for the current version and any libraries that depend on it.
As a result, we've published Firebase to the npm to make it more accessible to Node.js developers. You can install it with the following command:
npm install firebase
Here's a simple example of using Firebase in Node.js:
var Firebase = require('firebase'); var dataRef = new Firebase('https://myprojectname.firebaseIO-demo.com/'); dataRef.set("hello world!");
Installing the Firebase package will also install the firebase-token-generator package. This allows you to create authentication tokens on your own servers and is one of the three authentication options we offer. Here's a quick example:
var FirebaseTokenGenerator = require("firebase-token-generator"); var tokenGenerator = new FirebaseTokenGenerator(YOUR_FIREBASE_SECRET); var token = tokenGenerator.createToken({uid: "1", some: "arbitrary", data: "here"});
You can learn more about our token generator for Node.js here.
If you want to learn more about our Node support, a good place to start is our Node.js Quickstart Guide. You may also be interested in our Firebase Work Queue project on Github, which shows how Firebase can be used as a job queue for Node.js.
We’re excited to better serve the vibrant Node community, and we can't wait to see what you build!