ra-data-firebase-client
ra-data-firebase-client copied to clipboard
firebase data provider for react-admin framework
ra-data-firebase-client
Requirements
npm install firebase
Install
npm install ra-data-firebase-client
Usage
import { Admin, Resource } from 'react-admin'
import firebaseDataProvider from 'ra-data-firebase-client'
import firebase from 'firebase/app'
import "firebase/database";
firebase.initializeApp({
apiKey: '**************',
authDomain: '**************',
databaseURL: 'https://myrealtimedatabase.firebaseio.com',
projectId: 'myrealtimedatabase',
storageBucket: 'myrealtimedatabase.appspot.com',
messagingSenderId: '**************',
appId: '**************',,
measurementId: '**************'
})
const settings = {context: 'dev', imagekey: "images", filekey: "files"}
export default () =>
<Admin dataProvider={firebaseDataProvider(firebase, settings)}>
<Resource
name='posts'
list={PostList}
edit={PostEdit}
create={PostCreate} />
</Admin>
Result
{
"myrealtimedatabase": {
"dev" : {
"posts" : {
"-M6rfMORj0dfoisK1taJ" : {
"id" : "-M6rfMORj0dfoisK1taJ",
"key1" : "value1",
"key2" : "value2",
"images": [
{
"id": "-M6rfMORj0dfoisK1taJ_img_0"},
"src": "data:image/jpeg;base64......",
"size": 150402,
"title": "my-uploaded-image.jpg"
"type": "image"
{...},
{...}
]
"files": [
{
"id": "-M6rfMORj0dfoisK1taJ_img_0"},
"src": "data:application/pdf;base64......",
"size": 150402,
"title": "my-uploaded-file.pdf"
"type": "file"
{...},
{...}, {...}, {...}]
}
}
}
}
}
Demo
https://aymendhaya.github.io/ra-data-firebase-client
About authProvider
Firebase authProvider on versions < 3 has been moved to a separate project ra-auth-firebase-client