firecms icon indicating copy to clipboard operation
firecms copied to clipboard

Future Request: Support multiple databases in single project

Open Fsher07 opened this issue 2 years ago • 3 comments

As you know, we can now create more than one database and in my opinion it is very useful. Also firebase itself suggests to use the property to separate prod-staging environments. In FireCMS, it is very easy to do it. We just need to add a database id to useFirestoreDataSource hook. Then, use that parameter as the second input of getFireStore. If it empty, it automatically gets the default database

Fsher07 avatar Jan 15 '24 06:01 Fsher07

We are about to explore migrating to FireCMS to support our fully multi-tenant system (auth, firestore, storage, etc). Is there official or known support for this?

danielmahon avatar Jun 13 '25 18:06 danielmahon

Hi @danielmahon, Right now it is possible to use multiple Firestore databases within the same Firebase instance, as well as having multiple Firestore databases in different Firebase projects! If you have some custom requirements related to auth or storage, we can help you with it :) Feel free to book a session with us in https://calendar.google.com/calendar/u/0/appointments/schedules/AcZssZ0INW8ihjQ90S4gkdo8_rbL_Zx7gagZShLIpHyW43zDXkQDPole6a1coo1sT2O6Gl05X8lxFDlp?gv=true

fgatti675 avatar Jun 13 '25 20:06 fgatti675

This is supported, and it landed pretty much exactly as you proposed — thanks for the precise suggestion.

Set databaseId on the collection; it flows down to the Firestore instance for every read and write on that collection. Omit it and you get the default database.

import { buildCollection } from "@firecms/core";

const stagingProducts = buildCollection({
    name: "Products (staging)",
    path: "products",
    databaseId: "staging",   // <-- named Firestore database
    properties: { /* ... */ }
});

Available since 3.0.0. It's honoured by the Firestore data source and by the text search controllers, so filtering, sorting and search all target the right database.

Two scenarios both work today:

  • multiple Firestore databases within one Firebase project (your prod/staging split)
  • multiple Firestore databases across different Firebase projects

@danielmahon — for the multi-tenant case you asked about, this covers the Firestore side. Auth and Storage multi-tenancy need more than a databaseId and are worth a conversation: https://firecms.co/docs/self/main_components

Closing — please reopen or open a new issue if you hit a specific gap.

marianmoldovan avatar Jul 29 '26 12:07 marianmoldovan