react-admin-firebase-webpack-fix
v0.5.5
Published
A firebase data provider for the React Admin framework
Downloads
6
Readme
react-admin-firebase
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
- [x] Firebase Authenticated Login (email, password)
- [x] Dynamic caching of resources
- [x] All methods implemented;
(GET, POST, GET_LIST ect...)
- [x] Filtering, sorting etc...
- [x] 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);
...