An admin-on-rest client for Firebase.
npm install aor-firebase-client --save
// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import { PostList } from './posts';
import { RestClient } from 'aor-firebase-client';
const firebaseConfig = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>',
messagingSenderId: '<your-sender-id>'
};
const trackedResources = ['posts']
const App = () => (
<Admin restClient={RestClient(trackedResources, firebaseConfig)} >
<Resource name="posts" list={PostList} />
</Admin>
);
export default App;
The package lets you manage the login/logout process implementing an optional authClient
prop of the Admin
component (see documentation).
It stores a firebaseToken
in localStorage
.
// in src/App.js
...
import {RestClient, AuthClient} from 'aor-firebase-client';
const firebaseConfig = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>',
messagingSenderId: '<your-sender-id>'
};
const App = () => (
<Admin restClient={RestClient(firebaseConfig)} authClient={AuthClient}>
<Resource name="posts" list={PostList} />
</Admin>
);
export default App;
Note: AuthClient does require using the RestClient in order to initialize firebase. Alternatively, you can opt to not use the RestClient and initialize firebase yourself like this:
import {RestClient, AuthClient} from 'aor-firebase-client';
import firebase from 'firebase';
const firebaseConfig = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>',
messagingSenderId: '<your-sender-id>'
};
firebase.initializeApp(firebaseConfig);
const App = () => (
<Admin authClient={AuthClient}>
<Resource name="posts" list={PostList} />
</Admin>
);
export default App;
- README Fixes ( Thanks to @RWOverdijk in #4 )
- CI configured
- Fixed Auth Client configuration ( Thanks to @RWOverdijk in #2 )
- Added timestamps ( Thanks to @BilalBudhani in #3 )
- Initial unit testing / CI
- Initial commit, lots of to dos
This library is licensed under the MIT Licence.