Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
Firebase v9 Database. ref is not a function?

I've started migrating over to v9 Modular firebase. Please see my config:

import { initializeApp } from 'firebase/app';
import { getDatabase } from "firebase/database";

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
..
};

const app = initializeApp(firebaseConfig);
// Get a reference to the database service
export const database = getDatabase(app);

Then in another file I made basic CRUD functions.

import { database } from "./firebase"

export const insertTestData = () => {
    return database.ref("test").set({name:"hello world"})
}

I got the following error:

Uncaught TypeError: _firebase__WEBPACK_IMPORTED_MODULE_0__.database.ref is not a function

Did I miss anything?

I'm not sure why it's also not picking up imports

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are importing ref() from Modular SDK but still using name-spaced syntax. Try:

import { getDatabase, ref, set } from "firebase/database";

export const insertTestData = () => {
  return set(ref(database, "test"), { name: "hello" })
}

Make sure you are referring to the "Modular" tab of the code snippets in the documentation

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda