react-admin-firebase-webpack-fix
TypeScript icon, indicating that this package has built-in type declarations

0.5.5 • Public • Published

react-admin-firebase

NPM Version License Downloads/week Github Issues

A firebase data provider for the React-Admin framework. It maps collections from the Firebase database (Firestore) to your react-admin application. It's an npm package!

Features

  • Firebase Authenticated Login (email, password)
  • Dynamic caching of resources
  • All methods implemented; (GET, POST, GET_LIST ect...)
  • Filtering, sorting etc...
  • Realtime updates, using ra-realtime
    • Implicitly watches all GET_LIST routes using observables with the firebase sdk
    • Optional watch collection array or dontwatch collection array

Get Started

yarn add react-admin-firebase

or

npm install --save react-admin-firebase

Demo Basic

A simple example based on the React Admin Tutorial.

Prerequisits

  • Create a posts collection in the firebase firestore database
  • Get config credentials using the dashboard

Code

import * as React from 'react';
import { Admin, Resource } from 'react-admin';
 
import { PostList, PostShow, PostCreate, PostEdit } from "./posts";
import { FirebaseDataProvider } from 'react-admin-firebase';
 
const config = {
  apiKey: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
  authDomain: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
  databaseURL: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
  projectId: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
  storageBucket: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
  messagingSenderId: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
};
 
const dataProvider = FirebaseDataProvider(config);
 
class App extends React.Component {
  public render() {
    return (
      <Admin 
        dataProvider={dataProvider} 
      >
        <Resource name="posts" list={PostList} show={PostShow} create={PostCreate} edit={PostEdit}/>
      </Admin>
    );
  }
}
 
export default App;

(Optional) Realtime Updates!

Get realtime updates from the firebase server instantly on your tables, with minimal overheads, using rxjs observables!

...
import {
  FirebaseRealTimeSaga,
  FirebaseDataProvider
} from 'react-admin-firebase';
...
const dataProvider = FirebaseDataProvider(config);
const firebaseRealtime = FirebaseRealTimeSaga(dataProvider);
 
class App extends React.Component {
  public render() {
    return (
      <Admin 
        dataProvider={dataProvider} 
        customSagas={[firebaseRealtime]}
      >
        <Resource name="posts" list={PostList} show={PostShow} create={PostCreate} edit={PostEdit}/>
      </Admin>
    );
  }
}
 
export default App;

(Optional) Realtime Options

Trigger realtime on only some routes using the options object.

...
const dataProvider = FirebaseDataProvider(config);
const options = {
  watch: ['posts', 'comments'],
  dontwatch: ['users']
}
const firebaseRealtime = FirebaseRealTimeSaga(dataProvider, options);
...

Full Demo Project

Readme

Keywords

none

Package Sidebar

Install

npm i react-admin-firebase-webpack-fix

Weekly Downloads

4

Version

0.5.5

License

MIT

Unpacked Size

712 kB

Total Files

31

Last publish

Collaborators

  • jacob.haskins