0

I have imported firebase like this,

import * as firebase from 'firebase';

const config = {

};
firebase.initializeApp(config);

export const database = firebase.database().ref('/posts');

Then I got this error:

__WEBPACK_IMPORTED_MODULE_0_firebase_app__.database is not a function

so I tried this way.

const firebase = require('firebase/app');
require('firebase/auth');
require('firebase/database');

Then I got this error.

firebase.initializeApp is not a function

Does anyone know how to work with server side rendered react with webpack, firebase ?

Thanks.

  • Possible duplicate of [firebase.database is not a function](https://stackoverflow.com/questions/38248723/firebase-database-is-not-a-function) – Gopinath Kaliappan Feb 28 '18 at 05:43

1 Answers1

0

instead of

export const database = firebase.database().ref('/posts')

try :

const database = firebase.database().ref('/posts')
module.exports = database
Egor Egorov
  • 705
  • 3
  • 10
  • 22