Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda