1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Update with-firebase-auth example (#5742)

- The with-firebase-auth example won't run unless a database with proper rules is created first. 
- Add a small error callback to addDbListener to help with debugging if someone's database connection doesn't work.
This commit is contained in:
Obed Marquez Parlapiano 2018-11-25 14:57:15 +01:00 committed by Tim Neutkens
parent d6d9dd1e42
commit b63487c331
2 changed files with 3 additions and 0 deletions

View file

@ -29,6 +29,7 @@ Set up firebase:
- Get your authentication credentials from the Firebase console under *authentication>users>web setup*. It will include keys like `apiKey`, `authDomain` and `databaseUrl` and it goes into your project in `credentials/client.js`.
- Copy the `databaseUrl` key you got in the last step into `server.js` in the corresponding line.
- Back at the Firebase web console, go to *authentication>signup method* and select *Google*.
- Create a database in the "Database" tab and select the realtime database. Then go to "rules" and set up your write, read rules. Examples can be found here: https://firebase.google.com/docs/database/security/quickstart#sample-rules
Install it and run:

View file

@ -59,6 +59,8 @@ export default class Index extends Component {
firebase.database().ref('messages').on('value', snap => {
const messages = snap.val()
if (messages) this.setState({ messages })
}, (error) => {
console.error(error)
})
}