Delete a document from Firestore by id without hardcoding a specific id

Solution for Delete a document from Firestore by id without hardcoding a specific id
is Given Below:

I have an app that lets the user add albums to a list. I want to delete a document (album) from Firestore by ID. I can do so with the following:

const removeAlbum = async (id) => {
  await db.collection('albums').doc(id).delete();
  console.log(id);
  return id;
};

<button onClick={() => removeAlbum('beokyoi80u45MFlWPL1A')}>

Is there a way to do this without actually specifying the ID, e.g., “beokyoi80u45MFlWPL1A”?

No, you need a reference to that document you want to delete. When you fetch the albums on page load, you should store that ID in that element’s data so you can use it later to delete it.