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

251
Visualizações
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 Respostas
Responde à pergunta

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 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