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.
- 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
yarn add react-admin-firebase
or
npm install --save react-admin-firebase
Make sure to make a release when you want consumers to be able to easily pull it.
When added as a gitHub dependency to a package.json
we consider referencing a specific release tag. This makes it easier for developers to keep an overview.
yarn build
- Commit everything
npm version [<newversion> | major | minor | patch
Take note of the output version.
Example:
$> yarn version --patch
yarn version v1.12.3
info Current version: 0.3.3
info New version: 0.3.4
✨ Done in 0.13s.
- Make a Pull Request or push to
master
depending on your team's process.
A simple example based on the React Admin Tutorial.
- Create a
posts
collection in the firebase firestore database - Get config credentials using the dashboard
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;
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;
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);
...