5 minute quickstart

Web Quickstart

Create an account

The first thing you need to do to get started with Firebase is sign up for a free account. A brand new Firebase will automatically be created for you with its own unique URL ending in firebaseio.com. We'll use this URL to store and sync data.

Install Firebase

To include the Firebase client library in your website, add a script tag to the <head> section of your HTML file. We recommend including the library directly from our CDN:

<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

Firebase is also available as a Bower dependency via "bower install firebase".

Node.js Setup

The Firebase JavaScript API and the Firebase Node.js API are exactly the same. Firebase clients run just as easily on your servers as they do on end-user devices. We offer a Node.js module which can be installed via npm from the command line:

$ npm install firebase --save

To use the Firebase Node.js module in your application, just require the Firebase client library.

var Firebase = require("firebase");

Read & Write to your Firebase

To read and write data from your Firebase, we need to first create a reference to it. We do this by passing the URL of your Firebase into the Firebase constructor:

var myFirebaseRef = new Firebase("https://<your-firebase>.firebaseio.com/");

There are several other ways to create a reference to a location in your Firebase. These are all explained in our understanding data section.

Writing Data

Once we have a reference to your Firebase, we can write any valid JSON object to it using set(). Our guide on saving data to Firebase explains the different write methods our API offers and how to know when the data has been successfully written to your Firebase.

  title: "Hello World!",
  author: "Firebase",
  location: {
    city: "San Francisco",
    state: "California",
    zip: 94103

Reading Data

Reading data from your Firebase is accomplished by attaching callbacks and handling the resulting events. Assuming we already wrote to myFirebaseRef above, we can retrieve the city value by using the on() method:

myFirebaseRef.child("location/city").on("value", function(snapshot) {
  alert(snapshot.val());  // Alerts "San Francisco"
Call val() on the DataSnapshot returned from the callback to access a JSON object.

In the example above, the value event will fire once for the initial state of the data, and then again every time the value of that data changes. You can learn more about the various event types and how to handle event data in our documentation on reading data.

Deploy Your Site with Firebase Hosting

Firebase Hosting lets you deploy your application's static files (HTML, CSS, JavaScript, etc) to the web with a single command. To get started, download firebase-tools via npm:

$ npm install -g firebase-tools

Read through our hosting quickstart to get your site up and running in minutes. Firebase Hosting is a production-grade service, with security, reliability, and scalability baked-in. We host your content on a global CDN and even provision an SSL certificate automatically for you so you can be up-and-running with only the following command:

$ firebase deploy
Paid Firebase apps can serve their files from a custom domain name!

Add Authentication

Firebase provides full support for authenticating users. For common login options such as email and password, Facebook, Twitter and Google, check out our guide on User Authentication. More advanced users may want to use custom login for complete control over user management and authentication.

Use Firebase to manage your authentication

Secure Your Firebase

Use our powerful expression-based Security and Firebase Rules to control access to your data and validate input:

  ".read": true,
  ".write": "auth.uid === 'admin'",
  ".validate": "newData.isString() && newData.val().length < 500"

Firebase enforces your Security and Firebase Rules consistently whenever data is accessed. The rules language is designed to be both powerful and flexible, so that you can maintain fine-grained control over your application's data.

Explore Our Bindings

In addition to our core API, we have bindings for AngularJS, Backbone, Ember, and ReactJS which make it even easier to use Firebase with those frameworks.

AngularJS, EmberJS, Backbone.js, Javascript, iOS7, OSX, Android

What's Next?