Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-firestack

> 前端框架
Open source

A firestack v3 react-native implementation

711 stars0 likes3 views
WebsiteGitHub

About

A firestack v3 react-native implementation


This library is no longer maintained, use at your own risk or please seek alternatives on npm.


Firestack

Firestack makes using the latest Firebase straight-forward.

What

Firestack is a light-weight layer sitting atop the native Firebase libraries for iOS and Android and mirrors the React Native JS api as closely as possible.

For a detailed discussion of how Firestack works as well as how to contribute, check out our contribution guide.

Features

  • Nearly automatic, rapid setup on Firebase
  • Covers lots of awesome features of Firebase:
    • authentication
      • username and password
      • social auth (implemented in conjunction with react-native-oauth)
        • Facebook
        • Github
        • Google
        • Twitter
    • storage handling
      • upload files
      • download urls
      • download files
    • real-time database
    • presence out-of-the-box
    • analytics
    • Remote configuration
    • FCM (in-progress)
  • Redux support built-in (but not required)
  • Android and iOS support
  • Community supported and professionally backed
  • Intended on being as drop-dead simple as possible
  • And so much more

Example app

We have a working application example available in at fullstackreact/FirestackApp. Check it out for more details about how to use Firestack.

Why?

Firebase is awesome and it's combination with the Google Cloud Platform makes it super awesome. Sadly, the latest version of Firebase requires the window object. That's where Firestack comes in! Firestack provides a really thin layer that sits on top of the native Firebase SDKs and attempts to use the JavaScript library as much as possible rather than reinventing the wheel.

Installing

Getting react-native-firestack up and running in your app should be a 2 step process + 1 for each platform.

  1. Install the npm package
  2. Link the project with react-native link react-native-firestack
  3. To ensure Android is setup, check your MainApplication.java for the FirestackPackage() line.

Those steps in more detail:

Install the npm package with:

bash
npm install react-native-firestack --save

To use Firestack, we'll need to have a development environment that includes the same prerequisites of Firebase.

iOS (with cocoapods)

Unfortunately, due to AppStore restrictions, we currently do not package Firebase libraries in with Firestack. However, the good news is we've automated the process (with many thanks to the Auth0 team for inspiration) of setting up with cocoapods. This will happen automatically upon linking the package with react-native-cli.

Remember to use the ios/[YOUR APP NAME].xcworkspace instead of the ios/[YOUR APP NAME].xcproj file from now on.

We need to link the package with our development packaging. We have two options to handle linking:

Automatically with react-native-cli

React native ships with a link command that can be used to link the projects together, which can help automate the process of linking our package environments.

bash
react-native link react-native-firestack

Update the newly installed pods once the linking is done:

bash
cd ios && pod update --verbose

Manually

If you prefer not to use rnpm, we can manually link the package together with the following steps, after npm install:

  1. In XCode, right click on Libraries and find the Add Files to [project name].

  2. Add the node_modules/react-native-firestack/ios/Firestack.xcodeproj

  3. Ensure that the Build Settings of the Firestack.xcodeproj project is ticked to All and it's Header Search Paths include both of the following paths and are set to recursive:

  4. $(SRCROOT)/../../react-native/React

  5. $(SRCROOT)/../node_modules/react-native/React

  6. ${PROJECT_DIR}/../../../ios/Pods

  7. Setting up cocoapods

Since we're dependent upon cocoapods (or at least the Firebase libraries being available at the root project -- i.e. your application), we have to make them available for Firestack to find them.

Using cocoapods is the easiest way to get started with this linking. Add or update a Podfile at ios/Podfile in your app with the following:

ruby
source 'https://github.com/CocoaPods/Specs.git'
[
  'Firebase/Core',
  'Firebase/Auth',
  'Firebase/Storage',
  'Firebase/Database',
  'Firebase/RemoteConfig',
  'Firebase/Messaging'
].each do |lib|
  pod lib
end

target '[project name]' do
end

# target '[project test name]' do
# end

Then you can run (cd ios && pod install) to get the pods opened. If you do use this route, remember to use the .xcworkspace file.

If you don't want to use cocoapods, you don't need to use it! Just make sure you link the Firebase libraries in your project manually. For more information, check out the relevant Firebase docs at https://firebase.google.com/docs/ios/setup#frameworks.

Android

Full Android support is coming soon, as it currently supports a smaller feature-set than the iOS version. Just as we do with iOS, we'll need to install the library using npm and call link on the library:

bash
react-native link react-native-firestack

Firestack includes the Firebase libraries and will link those directly into our project automatically.

Manually

To install react-native-firestack manually in our project, we'll need to import the package from io.fullstack.firestack in our project's android/app/src/main/java/com/[app name]/MainApplication.java and list it as a package for ReactNative in the getPackages() function:

java
package com.appName;
// ...
import io.fullstack.firestack.FirestackPackage;
// ...
public class MainApplication extends Application implements ReactApplication {
    // ...

    @Override
    protected List getPackages() {
      return Arrays.asList(
          new MainReactPackage(),
            new FirestackPackage()
      );
    }
  };
  // ...
}

We'll also need to list it in our android/app/build.gradle file as a dependency that we want React Native to compile. In the dependencies listing, add the compile line:

java
dependencies {
  compile project(':react-native-firestack')
}

Add to AndroidManifest.xml file

diff
  
+   
+     
+       
+     
+   

+   
+     
+       
+     
+   

Firebase setup

The Firestack library is intended on making it easy to work with Firebase and provides a small native shim to the Firebase native code.

To add Firebase to your project, make sure to create a project in the Firebase console

Each platform uses a different setup method after creating the project.

iOS

After creating a Firebase project, click on the Add Firebase to your iOS app and follow the steps from there to add the configuration file. You do not need to set up a cocoapods project (this is already done through firestack). Make sure not to forget the Copy Files phase in iOS.

Download the Firebase config file and place it in your app directory next to your app source code:

Once you download the configuration file, make sure you place it in the root of your Xcode project. Every different Bundle ID (aka, even different project variants needs their own configuration file).

Lastly, due to some dependencies requirements, Firestack supports iOS versions 8.0 and up. Make sure to update the minimum version of your iOS app to 8.0.

Android

There are several ways to setup Firebase on Android. The easiest way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform.

google-services.json setup

If you prefer to include the default settings in the source of your app, download the google-services.json file provided by Firebase in the Add Firebase to Android platform menu in your Firebase configuration console.

Next you'll have to add the google-services gradle plugin in order to parse it.

Add the google-services gradle plugin as a dependency in the project level build.gradle android/build.gradle

java
buildscript {
  // ...
  dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.0.0'
  }
}

In your app build.gradle file, add the gradle plugin at the VERY BOTTOM of the file (below all dependencies) android/app/build.gradle

java
apply plugin: 'com.google.gms.google-services'

Usage

After creating a Firebase project and installing the library, we can use it in our project by importing the library in our JavaScript:

javascript
import Firestack from 'react-native-firestack'

We need to tell the Firebase library we want to configure the project. Firestack provides a way to configure both the native and the JavaScript side of the project at the same time with a single command:

javascript
const firestack = new Firestack();

We can pass custom options by passing an object with configuration options. The configuration object will be generated first by the native configuration object, if set and then will be overridden if passed in JS. That is, all of the following key/value pairs are optional if the native configuration is set.

option type Default Value Description
debug bool false When set to true, Firestack will log messages to the console and fire debug events we can listen to in js
bundleID string Default from app [NSBundle mainBundle] The bundle ID for the app to be bundled with
googleAppID string "" The Google App ID that is used to uniquely identify an instance of an app.
databaseURL string "" The database root (i.e. https://my-app.firebaseio.com)
deepLinkURLScheme string "" URL scheme to set up durable deep link service
storageBucket string "" The Google Cloud storage bucket name
androidClientID string "" The Android client ID used in Google AppInvite when an iOS app has it's android version
GCMSenderID string "" The Project number from the Google Developer's console used to configure Google Cloud Messaging
trackingID string "" The tracking ID for Google Analytics
clientID string "" The OAuth2 client ID for iOS application used to authenticate Google Users for signing in with Google
APIKey string "" The secret iOS API key used for authenticating requests from our app

For instance:

javascript
const configurationOptions = {
  debug: true
};
const firestack = new Firestack(configurationOptions);
firestack.on('debug', msg => console.log('Received debug message', msg))

API documentation

Firestack is broken up into multiple parts, based upon the different API features that Firebase provides.

All methods return a promise.

Authentication

Firestack handles authentication for us out of the box, both with email/password-based authentication and through oauth providers (with a separate library to handle oauth providers).

Android requires the Google Play services to installed for authentication to function.

listenForAuth()

Firebase gives us a reactive method for listening for authentication. That is we can set up

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javafirebasereact-nativereact-native-appreact-native-firebase

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架