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

252
Vistas
getFirebaseAdmin from next-firebase-auth causing TypeScript error

I'm using the following package next-firebase-auth and I'm calling getFirebaseAdmin from next-firebase-auth and when I try to use it I get the following error when I try to use db as a reference in doc(db).

Argument of type 'Firestore' is not assignable to parameter of type 'DocumentReference'. Type 'Firestore' is missing the following properties from type 'DocumentReference': converter, type, firestore, id, and 3 more.

API

import { doc, getDoc } from "firebase/firestore";
import { getFirebaseAdmin } from "next-firebase-auth";
import type { NextApiRequest, NextApiResponse } from "next";

export const getUserInfo = (req: NextApiRequest, res: NextApiResponse) => {
  const db = getFirebaseAdmin().firestore();
 
  const docRef = doc(db, "user", "SF");
  return res.status(200).json({ data: "hello" });
};

Do I need to use init?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use the db instance to retrieve the doc directly with db.collection("user").doc("SF").

You also have to call init before using getFirebaseAdmin. From the next-firebase-auth documentation:

Initializes next-firebase-auth, taking a config object. Must be called before calling any other method.

import { doc, getDoc } from "firebase/firestore";
import { init, getFirebaseAdmin } from "next-firebase-auth";
import type { NextApiRequest, NextApiResponse } from "next";

init({/* your init config here */});

export const getUserInfo = (req: NextApiRequest, res: NextApiResponse) => {
  const db = getFirebaseAdmin().firestore();
 
  const docRef = db.collection("user").doc("SF");
  return res.status(200).json({ data: "hello" });
};
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