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

252
Views
"query is not a function" Next Js getServerSideprops and firebase error

I'm using NextJS and firebase as my primary database for the app that I'm currently building for an NGO. and I ran into an issue.

import {
  collection,
  where,
  query,
  getDocs
} from '@firebase/firestore';
import { db } from '../../../services/firebase';

export async function getServerSideProps({query}) {
  
  const user = await getDocs(query(collection(db, 'members'), where('id', '==', query)))
  return {
    props: {
      // VisionInfo: JSON.stringify(user.docs.map(item => item.data()))
      json: JSON.stringify('Hello')
    }
  };
}

The only way to get Query from the URL in NextJS in serverSideProps is to use the keyword "query" but the same keyword is used to fetch firebase document. The error shows "query is not a function" Is there anyway I could get Query into serversideprops ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue arises because you also have "query" in getServerSideProps parameters. Try naming the import from Firestore SDK (or the query param) as shown below:

import { query as fireQuery } from '@firebase/firestore';

export async function getServerSideProps({query}) {
  const user = await getDocs(fireQuery(collection(db, 'members'), where('id', '==', query)))
  // use fireQuery here      ^^^
})
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!