prescottprue / redux-firebase

Redux bindings for Firebase
MIT License
7 stars 2 forks source link

redux-firebase

NPM version NPM downloads Quality Code Coverage Code Style License Build Status Dependency Status Backers on Open Collective

Gitter

Redux bindings for Firebase

Why?

Provide Framework/library agnostic Firebase bindings for redux similar to those available in react-redux-firebase and other similar libraries.

Features

Install

npm install --save redux-firebase

Use

Note: If you are just starting a new project, you may want to use v2.0.0 since it is has an even easier syntax. For clarity on the transition, view the v1 -> v2 migration guide

Include reactReduxFirebase in your store compose function and firebaseStateReducer in your reducers:

import { createStore, combineReducers, compose } from 'redux'
import { reduxFirebase, firebaseReducer } from 'react-redux-firebase'
import * as firebase from 'firebase'

// Add Firebase to reducers
const rootReducer = combineReducers({
  firebase: firebaseReducer
})

// Firebase config
const config = {
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>'
}
const rfConfig = { userProfile: 'users' } // react-redux-firebase config

// initialize firebase instance
firebase.initializeApp(config) // <- new to v2.*.*

// Add reduxReduxFirebase to compose
const createStoreWithFirebase = compose(
  reduxFirebase(firebase, rfConfig), // firebase instance as first argument
)(createStore)

// Create store with reducers and initial state
const store = createStoreWithFirebase(rootReducer, initialState)

Discussion

Join us on the redux-firebase gitter.

FAQ

  1. How is this different than react-redux-firebase?

    The future plan for is for react-redux-firebase to be powered by this library. redux-firebase will contain the redux specific internal logic which was originally created for react-redux-firebase. In this way, redux-firebase is front end framework agnostic,

  2. How do I help?

    • Join the conversion on gitter
    • Post Issues
    • Create Pull Requests