Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
TypeError: _firebaseConfig.default.database is not a function

I am trying to use firebase for my chat application developed using React Native and I am getting following error while pushing records into firebase.

[TypeError: _firebaseConfig.default.database is not a function. (In '_firebaseConfig.default.database()', '_firebaseConfig.default.database' is undefined)]

I have created a firebase configuration file as below.

firebase-config.js

import Firebase from 'firebase/compat/app';

const firebaseConfig = {
  apiKey: '',
  databaseURL: '',
  projectId: '',
  appId: '',
};

export default Firebase.initializeApp(firebaseConfig);


Messages.js

import Firebase from './firebase-config';

export const sendMessage = async (from, to, message) => {
  try {
    return await Firebase.database()
      .ref('messages/' + from)
      .child(to)
      .set({
        from: from,
        to: to,
        message: message,
      });
  } catch (error) {
    console.log(error);
  }
};

export const receiveMessage = async (from, to, message) => {
  try {
    return await getDatabase(Firebase)
      .ref('messages/' + to)
      .child(from)
      .push({
        from: from,
        to: to,
        message: message,
      });
  } catch (error) {
    console.log(error);
  }
};

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're not importing the Realtime Database SDK anywhere, so when you try to then access firebase.database() you get an error saying that it can't be found.

To fix this, import the Realtime Database SDK after you import Firebase from 'firebase/compat/app'.

import firebase from 'firebase/compat/app';
import 'firebase/database';
...

I recommend also checking out the example in the upgrade guide on updating imports to v9 compat.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!