prototypes

Firebase Login App

A sample React app using Firebase AuthUI and js-data

No live demo. Feel free to look around le source

To connect to Firebase

Create local app and add keys

REACT_APP_FIREBASE_API_KEY=
REACT_APP_FIREBASE_AUTH_DOMAIN=
REACT_APP_FIREBASE_DATABASE_URL=
REACT_APP_FIREBASE_PROJECT_ID=
REACT_APP_FIREBASE_STORAGE_BUCKET=
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=

Create firebase app and update keys

Add firebase to packages

Create new data files

import { DataStore } from 'js-data'
// import { LocalStorageAdapter } from 'js-data-localstorage'
import { FirebaseAdapter } from 'js-data-firebase'

window.firebase.initializeApp({
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
  databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL
})

const store = new DataStore()
const adapter = new FirebaseAdapter({
  db: window.firebase.database()
})

store.registerAdapter('firebase', adapter, { default: true })

export default store
import store from './store'

export default store.defineMapper('modelname')

Allow read / write access

Add authentication

{
  "rules": {
    ".read": "false || auth != null",
    ".write": "false || auth != null",
    "entry": {
      ".read": "auth != null",
      ".write": "auth != null"
    }
  }
}

Next