How to store and retrieve data from firebase (v9.0.0) database

I’m new to Google Firebase, React, and Javascript and attempting to make a Tinder Clone. I had trouble with my code and someone on StackOverflow helped me by fixing the errors that popped up in my code, but I’m now stuck figuring out how to store and retrieve (multiple) data from Firebase’s database. As far as I can understand, the code creates a query for the collection and then unsub stops the listener? This is the code someone of StackOverflow gave.

function SwipeCards() {

     const [buddies, setBuddies] = useState([]);

     useEffect(() => {
        const q = query(collection(database, 'buddies'))
        const unsub = onSnapshot(q, (querySnapshot) => {
            console.log('Data', =>;
    }, []);



I am trying to get from ‘collections: buddies’ which have the fields ‘name’,’picture’, and ‘info’ (hobbies, interests, etc.). These are for the cards one swipes left or right on. I can give more code on my project if needed and any information and help is greatly appreciated.


I believe the getDocs is the answer here. Check out the migration docs here.