Firebase is a great solution for creating a realtime back end for your ember app. Combined with EmberFire and Ember CLI you can quickly get up and running.

Originally I tried to create this app using Ember CLI .39 and the latest version of EmberFire. The application was constantly crashing. Version .40 of Ember CLI has fixed everything.

For this application I'm just going to create a simple model using ember data and save it to Firebase. (You can download the complete repo with the code on github here)


Let's use Ember CLI to create a new app. (Check out my last guide on Ember if needed)

$ ember new <app-name>

This can take several minutes. After this is done change directories into the new app and install emberFire. (@tikotzky has created a emberfire module that also includes the bower install, check out the comments for more information, it's called ember-cli-emberfire)

$ npm install --save emberfire

Next install the EmberFire bower files.

$ bower install --save emberfire

The bower command will add all the correct vendor files to the vendor/ directory. The EmberFire module will do all the linking so you don't have to edit the Brocfile.

Finally we'll need to generate some files that we'll fill in later.

$ ember generate adapter application
$ ember generate controller posts
$ ember generate template posts
$ ember generate model post
$ ember generate route index


We've created all the scaffolding and now it's time to create the application. It's probably a good time now to run the ember server and make sure no errors appear. If all is fine continue on.

Make sure to sign up for a Firebase account here. The free plan shoud be plenty to start with.

EmberFire is an adapter for Ember Data. After it's connected all your ember data models will be synced with Firebase. To connect the adapter edit the application.js file in the adapter folder.

// application.js
import DS from 'ember-data';

export default DS.FirebaseAdapter.extend({  
  firebase: new window.Firebase('https://<your-firebase>')

Make sure to update the URL with the one that was given after signing up with Firebase.

Next let's update the router.js file and add the route to posts.

... {  

Let's create a model for our posts.

import DS from 'ember-data';

export default DS.Model.extend({  
  title: DS.attr('string'),
  body: DS.attr('string'),
  timestamp: DS.attr('number')

Now we need to create a simple template for posts. It has a few text areas and a submit button.

<h2>New Post</h2>  
<ul class="post-publish">  
    {{input value=post.title placeholder="Title"}}
    {{textarea value=post.body placeholder="Body"}}
    <button {{action "publishPost"}}>Publish</button>

Next we need to create an ArrayController for posts that will handle the action publishPost.

export default Ember.ArrayController.extend({

  init: function() {
    this.set('post', Ember.Object.create());
  sortProperties: ['timestamp'],
  sortAscending: false, // sorts post by timestamp
  actions: {
    publishPost: function() {
      var newPost ='post', {
        title: this.get('post.title'),
        body: this.get('post.body'),
        timestamp: new Date()

This should be enough to post a message and have it saved into Firebase. You can double check your Firebase dashboard /posts to see the posts.

We want to show each post in the front page. Let's update the index template.

{{#each post in arrangedContent}}

Next we need to retrieve the posts using the index route.

import Ember from 'ember';

export default Ember.Route.extend({  
model: function() {  

That's it. Run ember server and check the :4200/posts URL. Try to submit a post and check back to the index.

Some more detailed information on EmberFire can be found in the firebase docs.

Good luck!