Get started with Cloud Firestore Enterprise edition

Preview:Firestore in Native mode (with Pipeline operations) for Enterpriseedition is subject to the "Pre-GA Offerings Terms" in the GeneralService Terms section of theService SpecificTerms. You can process personaldata for this feature as outlined in theCloud Data Processing Addendum, subjectto the obligations and restrictions described in the agreement under which youaccess Google Cloud. Pre-GA features are available "as is" and might havelimited support. For more information, see thelaunch stagedescriptions.

This quickstart shows you how to set up Cloud Firestore Enterprise edition, add data, thenuse either Core operations or Pipeline operations to query the data youjust added in theFirebase console.

Cloud Firestore supports mobile or web SDKs and server client libraries:

  • Cloud Firestore supportsSDKs for Android, iOS, and web and more. Combined withCloud Firestore Security Rules andFirebase Authentication, the mobile and web SDKs supportserverless app architectures where clients connect directly to yourCloud Firestore database.

  • Cloud Firestore supportsserver client libraries for Java, Node.js, andPython. Use these client libraries to set up privileged serverenvironments with full access to your database. Learn more about these librariesin theQuickstart for server client libraries.

Note: Before getting started with these features, make sure you're familiar withthedifferences between Core and Pipeline operations.

Create a Cloud Firestore Enterprise edition database

  1. If you haven't already, create a Firebase project: In theFirebase console, clickAdd project,then follow the on-screen instructions to create a Firebase project or toadd Firebase services to an existingGoogle Cloud project.

  2. Open your project in theFirebase console. In the left panel, expandBuild and then selectFirestore database.

  3. ClickCreate database.

  4. SelectEnterprise for the database mode.

  5. SelectFirestore in Native Mode for the operation mode, which supportsCore and Pipeline operations.

    Note: You can create a database in either Native mode or MongoDB compatibilitymode. For more information about MongoDB compatibility mode, see thequickstart for creating MongoDB compatible databases.
  6. Select alocation for your database.

  7. Select a starting mode for yourCloud Firestore Security Rules:

    Test mode

    Good for getting started with the mobile and web client libraries,but allows anyone to read and overwrite your data. After testing,makesure to review theSecure your data section.

    To get started with the web, Apple platforms, or Android SDK, select testmode.

    Production mode

    Denies all reads and writes from mobile and web clients.Your authenticated application servers (Python) can still access yourdatabase.

    Your initial set ofCloud Firestore Security Rules will apply to your defaultCloud Firestore database. If you create multiple databases for yourproject, you can deployCloud Firestore Security Rules for each database.

  8. ClickCreate.

Cloud Firestore andApp Engine: With support for multiple databases, you can use both Cloud Firestore Enterprise edition andDatastore in the same project. If you useApp Engine, note that only the(default) database in standard mode with Datastore or Firestore Native APIs can be used withApp Engine.

When you enable Cloud Firestore Enterprise edition, it also enables the API in theCloud API Manager.

Set up your development environment

Add the required dependencies and client libraries to your app.

Web

  1. Follow the instructions toadd Firebase to your web app.
  2. TheCloud Firestore SDK is available as an npm package.
    npminstallfirebase@12.9.0--save
    You'll need to import both Firebase andCloud Firestore.
    import{initializeApp}from"firebase/app";import{getFirestore}from"firebase/firestore";
Looking for a compact Firestore library, and only need simple REST/CRUD capabilities? Try the Firestore Lite SDK, available only via npm.
iOS+

Follow the instructions toadd Firebase to your Apple app.

Use Swift Package Manager to install and manage Firebase dependencies.

Visitour installation guide to learn about the different ways you can add Firebase SDKs to your Apple project, including importing frameworks directly and using CocoaPods.
  1. In Xcode, with your app project open, navigate toFile > Swift Packages > Add Package Dependency.
  2. When prompted, add the Firebase Apple platforms SDK repository:
  3.   https://github.com/firebase/firebase-ios-sdk
    Note: New projects should use the default (latest) SDK version, but you can choose an older version if needed.
  4. Choose the Firestore library.
  5. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.
Android
  1. Follow the instructions toadd Firebase to your Android app.
  2. Using theFirebase Android BoM, declare the dependency for theCloud Firestore library for Android in yourmodule (app-level) Gradle file (usuallyapp/build.gradle.kts orapp/build.gradle).
    dependencies{// Import the BoM for the Firebase platformimplementation(platform("com.google.firebase:firebase-bom:34.9.0"))// Declare the dependency for theCloud Firestore library// When using the BoM, you don't specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-firestore")}

    By using theFirebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

    (Alternative) Declare Firebase library dependencieswithout using theBoM

    If you choose not to use theFirebase BoM, you must specify each Firebase library version in its dependency line.

    Note that if you usemultiple Firebase libraries in your app, we highly recommend using theBoM to manage library versions, which ensures that all versions are compatible.

    dependencies{// Declare the dependency for theCloud Firestore library// When NOT using the BoM, you must specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-firestore:26.1.0")}

    Looking for a Kotlin-specific library module? Starting with theOctober 2023 release, both Kotlin and Java developers can depend on the main library module (for details, see theFAQ about this initiative).

InitializeCloud Firestore

Initialize an instance ofCloud Firestore:

Web

import{initializeApp}from"firebase/app";import{getFirestore}from"firebase/firestore";//TODO:Replacethefollowingwithyourapp's Firebase project configuration//See:https://support.google.com/firebase/answer/7015592constfirebaseConfig={FIREBASE_CONFIGURATION};//InitializeFirebaseconstapp=initializeApp(firebaseConfig);//WheninitializingFirestore,remembertousethenameofthedatabaseyoucreatedearlier:constdb=initializeFirestore(app,{},'your-new-enterprise-database');

ReplaceFIREBASE_CONFIGURATION with your web app'sfirebaseConfig.

To persist data when the device loses its connection, see theEnable Offline Data documentation.

Swift
importFirebaseCoreimportFirebaseFirestoreFirebaseApp.configure()//WheninitializingFirestore,remembertousethenameofthedatabaseyoucreatedearlier:letdb=Firestore.firestore(database:"your-new-enterprise-database")

Kotlin

// Access aCloud Firestore instance from your Activity// When initializing Firestore, remember to use the name of the database you created earlier:valfirestore=FirebaseFirestore.getInstance("your-new-enterprise-database")

Java

// Access aCloud Firestore instance from your Activity// When initializing Firestore, remember to use the name of the database you created earlier:FirebaseFirestorefirestore=FirebaseFirestore.getInstance("your-new-enterprise-database");

Add data using Core operations

In order to explore Core operations and Pipeline operations for querying data,add data to your database using Core operations.

Cloud Firestore stores data in Documents, which are stored inCollections.Cloud Firestore creates collections and documents implicitlythe first time you add data to the document. You don't need to explicitlycreate collections or documents.

Create a new collection and a document using the following example code.

Web

import{collection,addDoc}from"firebase/firestore";try{constdocRef=awaitaddDoc(collection(db,"users"),{first:"Ada",last:"Lovelace",born:1815});console.log("Document written with ID: ",docRef.id);}catch(e){console.error("Error adding document: ",e);}

Web

Learn more about the tree-shakeable modular Web API and its advantages over the namespaced API.
db.collection("users").add({first:"Ada",last:"Lovelace",born:1815}).then((docRef)=>{console.log("Document written with ID: ",docRef.id);}).catch((error)=>{console.error("Error adding document: ",error);});
Swift
Note: This product is not available on watchOS and App Clip targets.
// Add a new document with a generated IDdo{letref=tryawaitdb.collection("users").addDocument(data:["first":"Ada","last":"Lovelace","born":1815])print("Document added with ID:\(ref.documentID)")}catch{print("Error adding document:\(error)")}

Kotlin

// Create a new user with a first and last namevaluser=hashMapOf("first"to"Ada","last"to"Lovelace","born"to1815,)// Add a new document with a generated IDdb.collection("users").add(user).addOnSuccessListener{documentReference->Log.d(TAG,"DocumentSnapshot added with ID:${documentReference.id}")}.addOnFailureListener{e->Log.w(TAG,"Error adding document",e)}

Java

// Create a new user with a first and last nameMap<String,Object>user=newHashMap<>();user.put("first","Ada");user.put("last","Lovelace");user.put("born",1815);// Add a new document with a generated IDdb.collection("users").add(user).addOnSuccessListener(newOnSuccessListener<DocumentReference>(){@OverridepublicvoidonSuccess(DocumentReferencedocumentReference){Log.d(TAG,"DocumentSnapshot added with ID: "+documentReference.getId());}}).addOnFailureListener(newOnFailureListener(){@OverridepublicvoidonFailure(@NonNullExceptione){Log.w(TAG,"Error adding document",e);}});

Now add another document to theusers collection. Notice that this documentincludes a key-value pair (middle name) that does not appear in the firstdocument. Documents in a collection can contain different sets of information.

Web

// Add a second document with a generated ID.import{addDoc,collection}from"firebase/firestore";try{constdocRef=awaitaddDoc(collection(db,"users"),{first:"Alan",middle:"Mathison",last:"Turing",born:1912});console.log("Document written with ID: ",docRef.id);}catch(e){console.error("Error adding document: ",e);}

Web

Learn more about the tree-shakeable modular Web API and its advantages over the namespaced API.
// Add a second document with a generated ID.db.collection("users").add({first:"Alan",middle:"Mathison",last:"Turing",born:1912}).then((docRef)=>{console.log("Document written with ID: ",docRef.id);}).catch((error)=>{console.error("Error adding document: ",error);});
Swift
Note: This product is not available on watchOS and App Clip targets.
// Add a second document with a generated ID.do{letref=tryawaitdb.collection("users").addDocument(data:["first":"Alan","middle":"Mathison","last":"Turing","born":1912])print("Document added with ID:\(ref.documentID)")}catch{print("Error adding document:\(error)")}

Kotlin

// Create a new user with a first, middle, and last namevaluser=hashMapOf("first"to"Alan","middle"to"Mathison","last"to"Turing","born"to1912,)// Add a new document with a generated IDdb.collection("users").add(user).addOnSuccessListener{documentReference->Log.d(TAG,"DocumentSnapshot added with ID:${documentReference.id}")}.addOnFailureListener{e->Log.w(TAG,"Error adding document",e)}

Java

// Create a new user with a first, middle, and last nameMap<String,Object>user=newHashMap<>();user.put("first","Alan");user.put("middle","Mathison");user.put("last","Turing");user.put("born",1912);// Add a new document with a generated IDdb.collection("users").add(user).addOnSuccessListener(newOnSuccessListener<DocumentReference>(){@OverridepublicvoidonSuccess(DocumentReferencedocumentReference){Log.d(TAG,"DocumentSnapshot added with ID: "+documentReference.getId());}}).addOnFailureListener(newOnFailureListener(){@OverridepublicvoidonFailure(@NonNullExceptione){Log.w(TAG,"Error adding document",e);}});

Read data using Core operations

Use the data viewer in theFirebase consoleto quickly verify that you've added data toCloud Firestore.

You can also use the "get" method to retrieve the entire collection.

Web

import{collection,getDocs}from"firebase/firestore";constquerySnapshot=awaitgetDocs(collection(db,"users"));querySnapshot.forEach((doc)=>{console.log(`${doc.id} =>${doc.data()}`);});

Web

Learn more about the tree-shakeable modular Web API and its advantages over the namespaced API.
db.collection("users").get().then((querySnapshot)=>{querySnapshot.forEach((doc)=>{console.log(`${doc.id} =>${doc.data()}`);});});
Swift
Note: This product is not available on watchOS and App Clip targets.
do{letsnapshot=tryawaitdb.collection("users").getDocuments()fordocumentinsnapshot.documents{print("\(document.documentID) =>\(document.data())")}}catch{print("Error getting documents:\(error)")}

Kotlin

db.collection("users").get().addOnSuccessListener{result->for(documentinresult){Log.d(TAG,"${document.id} =>${document.data}")}}.addOnFailureListener{exception->Log.w(TAG,"Error getting documents.",exception)}

Java

db.collection("users").get().addOnCompleteListener(newOnCompleteListener<QuerySnapshot>(){@OverridepublicvoidonComplete(@NonNullTask<QuerySnapshot>task){if(task.isSuccessful()){for(QueryDocumentSnapshotdocument:task.getResult()){Log.d(TAG,document.getId()+" => "+document.getData());}}else{Log.w(TAG,"Error getting documents.",task.getException());}}});

Read data using Pipeline operations

Now you can compare the Pipeline query experience with the Core queryexperience.

Web

// The import/require of "firebase/firestore/pipelines" has a side-effect// of extending the Firestore class with the `.pipeline()` method.// Without this import/require, you will not be able to create a Pipeline.// import { execute } from "firebase/firestore/pipelines";constreadDataPipeline=db.pipeline().collection("users");// Execute the pipeline and handle the resulttry{constquerySnapshot=awaitexecute(readDataPipeline);querySnapshot.results.forEach((result)=>{console.log(`${result.id} =>${result.data()}`);});}catch(error){console.error("Error getting documents: ",error);}
Swift
do{// Initialize a Firestore Pipeline instance and specify the "users" collection as the// input stage.letsnapshot=tryawaitdb.pipeline().collection("users").execute()// Execute the pipeline to retrieve documents.// Iterate through the documents in the pipeline results, similar to a regular query// snapshot.forresultinsnapshot.results{print("\(result.id??"no ID") =>\(result.data)")}}catch{print("Error getting documents with pipeline:\(error)")}

Kotlin

valreadDataPipeline=db.pipeline().collection("users")// Execute the pipeline and handle the resultreadDataPipeline.execute().addOnSuccessListener{result->for(documentinresult){println("${document.getId()} =>${document.getData()}")}}.addOnFailureListener{exception->println("Error getting documents:$exception")}

Java

PipelinereadDataPipeline=db.pipeline().collection("users");readDataPipeline.execute().addOnSuccessListener(newOnSuccessListener<Pipeline.Snapshot>(){@OverridepublicvoidonSuccess(Pipeline.Snapshotsnapshot){for(PipelineResultresult:snapshot.getResults()){System.out.println(result.getId()+" => "+result.getData());}}}).addOnFailureListener(newOnFailureListener(){@OverridepublicvoidonFailure(@NonNullExceptione){System.out.println("Error getting documents: "+e);}});

Secure your data for mobile and web SDKs

If you're using the web, Android, or Apple platforms SDK, useFirebaseAuthentication andCloud Firestore Security Rules to secure your data inCloud Firestore.

Here are some basic rule sets you can use to get started. You can modify yoursecurity rules in theRulestab ofthe console.

Auth required

// Allow read/write access to a document keyed by the user's UIDservicecloud.firestore{match/databases/{database}/documents{match/users/{uid}{allowread,write:ifrequest.auth!=null &&request.auth.uid==uid;}}}

Production mode

// Deny read/write access to all users under any conditionsservicecloud.firestore{match/databases/{database}/documents{match/{document=**}{allowread,write:iffalse;}}}

Before you deploy your web, Android, or iOS app to production, also take stepsto ensure that only your app clients can access yourCloud Firestore data.See theApp Check documentation.

If you're using one of the server SDKs, useIdentity and Access Management(IAM) to secure your datainCloud Firestore.

Next steps

Deepen your knowledge of Core and Pipeline operations with the following topics:

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.