Firebase Kotlin Sdk

A Kotlin-first SDK for Firebase
Alternatives To Firebase Kotlin Sdk
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Firebase Ios Sdk4,724
7,3276 hours ago212November 14, 2023366apache-2.0Objective-C
Firebase SDK for Apple App Development
Firebase Js Sdk4,624
9 hours ago577otherTypeScript
Firebase Javascript SDK
Firebase Php2,03413143a day ago218November 25, 202315mitPHP
Unofficial Firebase Admin SDK for PHP
Chat Sdk Android1,58919a month ago15November 05, 20238otherJava
Chat SDK Android - Open Source Mobile Messenger
Firebase Admin Node1,5288,5822,2725 days ago128November 23, 2023171apache-2.0TypeScript
Firebase Admin Node.js SDK
Firebase Admin Go1,0243025 days ago57November 23, 202351apache-2.0Go
Firebase Admin Go SDK
Nativescript Plugin Firebase1,018125128 months ago159November 05, 2020594mitTypeScript
:fire: NativeScript plugin for Firebase
Firebase Functions1,0005,9625727 days ago102November 02, 202375mitTypeScript
Firebase SDK for Cloud Functions
Firebase Admin Python9182241758 days ago49June 22, 202397apache-2.0Python
Firebase Admin Python SDK
Chat Sdk Ios895
52 months ago112October 06, 202345otherObjective-C
Chat SDK iOS - Open Source Mobile Messenger
Alternatives To Firebase Kotlin Sdk
Select To Compare

Alternative Project Comparisons

Firebase Kotlin SDK GitHub last commit

Built and maintained with 🧡 by GitLive
Development teams merge faster with GitLive

The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the Firebase Android SDK Kotlin Extensions but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting iOS, Android, Desktop or Web, enabling the use of Firebase as a backend for Compose Multiplatform, for example.

Available libraries

The following libraries are available for the various Firebase products.

Service or Product Gradle Dependency API Coverage
Authentication dev.gitlive:firebase-auth:1.10.4 80%
Realtime Database dev.gitlive:firebase-database:1.10.4 70%
Cloud Firestore dev.gitlive:firebase-firestore:1.10.4 60%
Cloud Functions dev.gitlive:firebase-functions:1.10.4 80%
Cloud Messaging dev.gitlive:firebase-messaging:1.10.4 0%
Cloud Storage dev.gitlive:firebase-storage:1.10.4 40%
Installations dev.gitlive:firebase-installations:1.10.4 90%
Remote Config dev.gitlive:firebase-config:1.10.4 20%
Performance dev.gitlive:firebase-perf:1.10.4 1%
Crashlytics dev.gitlive:firebase-crashlytics:1.10.4 80%

Is the Firebase library or API you need missing? Create an issue to request additional API coverage or be awesome and submit a PR

Kotlin-first design

Unlike the Kotlin Extensions for the Firebase Android SDK this project does not extend a Java based SDK so we get the full power of Kotlin including coroutines and serialization!

Suspending functions

Asynchronous operations that return a single or no value are represented by suspending functions in the SDK instead of callbacks, listeners or OS specific types such as Task, for example:

suspend fun signInWithCustomToken(token: String): AuthResult

It is important to remember that unlike a callback based API, wating for suspending functions to complete is implicit and so if you don't want to wait for the result you can launch a new coroutine:

//TODO don't use GlobalScope
GlobalScope.launch {


Asynchronous streams of values are represented by Flows in the SDK instead of repeatedly invoked callbacks or listeners, for example:

val snapshots: Flow<DocumentSnapshot>

The flows are cold, which means a new listener is added every time a terminal operator is applied to the resulting flow. A buffer with the default size is used to buffer values received from the listener, use the buffer operator on the flow to specify a user-defined value and to control what happens when data is produced faster than consumed, i.e. to control the back-pressure behavior. Often you are only interested in the latest value received, in this case you can use the conflate operator to disable buffering.

The listener is removed once the flow completes or is cancelled.


The official Firebase SDKs use different platform-specific ways to support writing data with and without custom classes in Cloud Firestore, Realtime Database and Functions.

The Firebase Kotlin SDK uses Kotlin serialization to read and write custom classes to Firebase. To use Kotlin serialization in your project add the plugin to your gradle file:

plugins {
    kotlin("multiplatform") version "1.8.20" // or kotlin("jvm") or any other kotlin plugin
    kotlin("plugin.serialization") version "1.8.20"

Then mark you custom classes @Serializable:

data class City(val name: String)

Instances of these classes can now be passed along with their serializer to the SDK:

db.collection("cities").document("LA").set(City.serializer(), city, encodeDefaults = true)

The encodeDefaults parameter is optional and defaults to true, set this to false to omit writing optional properties if they are equal to theirs default values. Using @EncodeDefault on properties is a recommended way to locally override the behavior set with encodeDefaults.

You can also omit the serializer but this is discouraged due to a current limitation on Kotlin/JS and Kotlin/Native

Server Timestamp

Firestore and the Realtime Database provide a sentinel value you can use to set a field in your document to a server timestamp. So you can use these values in custom classes:

data class Post(
    // In case using Realtime Database.
    val timestamp = ServerValue.TIMESTAMP,
    // In case using Cloud Firestore.
    val timestamp: Timestamp = Timestamp.ServerTimestamp,
    // or
    val alternativeTimestamp = FieldValue.serverTimestamp,
    // or
    @Serializable(with = DoubleAsTimestampSerializer::class),
    val doubleTimestamp: Double = DoubleAsTimestampSerializer.serverTimestamp

In addition firebase-firestore provides [GeoPoint] and [DocumentReference] classes which allow persisting geo points and document references in a native way:

data class PointOfInterest(
    val reference: DocumentReference, 
    val location: GeoPoint
val document = PointOfInterest(
    reference = Firebase.firestore.collection("foo").document("bar"),
    location = GeoPoint(51.939, 4.506)

Polymorphic serialization (sealed classes)

This sdk will handle polymorphic serialization automatically if you have a sealed class and its children marked as Serializable. It will include a type property that will be used to discriminate which child class is the serialized.

You can change this type property by using the @FirebaseClassDiscrminator annotation in the parent sealed class:

sealed class Parent {
    data class Child(
        val property: Boolean
    ) : Parent

In combination with a SerialName specified for the child class, you have full control over the serialized data. In this case it will be:

  "class": "child",
  "property": true

Default arguments

To reduce boilerplate, default arguments are used in the places where the Firebase Android SDK employs the builder pattern:

UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
        .setDisplayName("Jane Q. User")

        .addOnCompleteListener(new OnCompleteListener<Void>() {
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Log.d(TAG, "User profile updated.");


user.updateProfile(displayName = "state", photoURL = "CA")

Named arguments

To improve readability functions such as the Cloud Firestore query operators use named arguments:

citiesRef.whereEqualTo("state", "CA")
citiesRef.whereArrayContains("regions", "west_coast")


citiesRef.where("state", equalTo = "CA")
citiesRef.where("regions", arrayContains = "west_coast")

Operator overloading

In cases where it makes sense, such as Firebase Functions HTTPS Callable, operator overloading is used:

    val addMessage = functions.getHttpsCallable("addMessage")
    //In the official android Firebase SDK this would be
    addMessage(mapOf("text" to text, "push" to true))


The Firebase Kotlin SDK provides a common API to access Firebase for projects targeting iOS, Android and JS meaning you can use Firebase directly in your common code. Under the hood, the SDK achieves this by binding to the respective official Firebase SDK for each supported platform.

It uses the Firebase Java SDK to support the JVM target.

Accessing the underlying Firebase SDK

In some cases you might want to access the underlying official Firebase SDK in platform specific code, for example when the common API is missing the functionality you need. For this purpose each class in the SDK has android, ios and js properties which holds the equivalent object of the underlying official Firebase SDK.

These properties are only accessible from the equivalent target's source set. For example to disable persistence in Cloud Firestore on Android you can write the following in your Android specific code (e.g. androidMain or androidTest): = FirebaseFirestoreSettings.Builder(


If you'd like to contribute to this project then you can fork this repository. You can build and test the project locally.

  1. Open the project in IntelliJ IDEA.
  2. Install cocoapods via sudo gem install -n /usr/local/bin cocoapods
  3. Install the GitLive plugin into IntelliJ
  4. After a gradle sync then run publishToMavenLocal
Popular Firebase Projects
Popular Sdk Projects
Popular Data Storage Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Firebase Database
Firebase Auth
Kotlin Coroutines
Firebase Functions