Can you use MongoDB with Firebase Hosting?

Viewed 945

So I'm making a web app with React, Next.js and MongoDB and I'm looking at hosting it on Firebase.

I heard it has it's own built in database similar to MongoDB, but it doesn't have text search which is a significant drawback for what I want to make.

I was wondering if it's possible to run MongoDB natively on Firebase, or if not, if I can just use MongoDB Atlas.

2 Answers

Firebase Hosting only serves static assets itself. It does not run any code you might have in those files, so it is not possible to run MongoDB directly on Firebase Hosting.

Accessing the cloud-hosted MongoDB is possible. The how depends on where the code that accesses MongoDB is run:

  • If you want to access MongoDB directly from the client-side code (through Realm it seems), you can host that client-side code on Firebase Hosting without any additional steps.
  • If you want to access MongoDB from server-side code, that isn't directly built into Firebase Hosting, but you can use its integration with Cloud Functions and Cloud Run to accomplish it.

You can do text search in Firebase + Firestore using a 3rd party tool and link is here https://firebase.google.com/docs/firestore/solutions/search .

Firebase can be used with MongoDB. Also, you can use MongoDB from Atlas or you can run it on GCP servers itself. Check GCP marketplace for easy installation of MongoDB.

Related