title: How to get single element from firebase
body: <p>I fetch all the data from the firebase database, showing it in the list. Now what I want do when I click on a particular element, all the data of that particular element only fetch.
  I am using Next.js/react.js
  a basic file that manages firebase connection</p>
  <pre><code>// Import the functions you need from the SDKs you need
  import { initializeApp } from &quot;firebase/app&quot;
  
  import { getFirestore } from &quot;@firebase/firestore&quot;
  // TODO: Add SDKs for Firebase products that you want to use
  // https://firebase.google.com/docs/web/setup#available-libraries
  
  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  const firebaseConfig = {
    apiKey: &quot;A#########################I&quot;,
    authDomain: &quot;clion-project.firebaseapp.com&quot;,
    projectId: &quot;clion-project&quot;,
    storageBucket: &quot;clion-project.appspot.com&quot;,
    messagingSenderId: &quot;8#########&quot;,
    appId: &quot;1:86735948933:web:46352###############&quot;,
    measurementId: &quot;G-KZG7P8MRW2&quot;,
  }
  
  // Initialize Firebase
  const app = initializeApp(firebaseConfig)
  export const db = getFirestore(app)
  </code></pre>
  <p>How I am getting the list of elements:</p>
  <pre><code>const usersCollectionRef = collection(db, &quot;Patients&quot;) 
  const [user, setUsers] = useState([])
  const q = query(usersCollectionRef)
    onSnapshot(q, (QuerySnapshot) =&gt; {
      setUsers(
        QuerySnapshot.docs.map((doc) =&gt; ({
          id: doc.id,
          data: doc.data(),
        }))
      )
    })
  </code></pre>
  <p>Now How I query a particular element from the list using its ID?</p>