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

250
Views
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 answers
Answer question

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