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

383
Views
Firebase Analytics con Next.js - ventana no definida

Estoy tratando de implementar y exportar el módulo de análisis de firebase en Next.js (firebase v9)

Recibo el error "ReferenceError: la ventana no está definida" para el siguiente fragmento de código. Todas las funciones anteriores funcionando muy bien.

Alguna idea de cómo solucionar este problema?

 import { initializeApp, getApps, getApp } from "firebase/app"; import { getAnalytics } from "firebase/analytics"; import { getAuth } from 'firebase/auth' import { getFirestore } from '@firebase/firestore' const firebaseConfig = { //... }; // Initialize Firebase const app = !getApps().length ? initializeApp(firebaseConfig) : getApp(); const auth = getAuth(); const db = getFirestore(app) // try to add analytics const analytics = getAnalytics(app) export {auth, db, analytics}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

SiguienteJS:

 import {initializeApp} from 'firebase/app'; import {getFirestore} from 'firebase/firestore'; import {getAnalytics} from 'firebase/analytics'; const firebaseConfig = JSON.parse( process?.env?.FIREBASE_CONFIG ?? '{}', ); let analytics; let firestore; if (firebaseConfig?.projectId) { // Initialize Firebase const app = initializeApp(firebaseConfig); if (app.name && typeof window !== 'undefined') { analytics = getAnalytics(app); } // Access Firebase services using shorthand notation firestore = getFirestore(); } export {analytics, firestore};
about 4 years ago · Juan Pablo Isaza Report

0

El SDK de la versión 9 no busca el objeto de ventana. Tendrá que implementar su propia verificación con algo como typeof window !== "undefined" .

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!