# expo-firebase-database

> Expo Unimodule for interfacing with Firebase Database

Latest version **2.0.0** (published 2019-01-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install expo-firebase-database
pnpm add expo-firebase-database
yarn add expo-firebase-database
bun add expo-firebase-database
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-01-04 |
| First published | 2018-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 149.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52353 |
| Author | 650 Industries, Inc. |
| Maintainers | barthec, brentvatne, ccheever, dsokal, esamelson, evanbacon, expoadmin, fson, ide, jakubste, jesseruder, nikki93, quinlanj, sjchmiela, terribleben, tsapeta |
| Keywords | react-native, flutter, expo, firebase, database, realtime |

## Links

- npm: https://www.npmjs.com/package/expo-firebase-database
- Repository: https://github.com/expo/expo
- Homepage: https://docs.expo.io/
- Issues: https://github.com/expo/expo/issues
- npm.io page: https://npm.io/package/expo-firebase-database

## Dependencies (2)

- [expo-core](https://npm.io/package/expo-core.md) ~2.0.0
- [expo-firebase-app](https://npm.io/package/expo-firebase-app.md) ~2.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-01-04
- 2.0.0-rc.2 (next) — 2019-01-03
- 2.0.0-rc.1 — 2018-12-20
- 2.0.0-rc.0 — 2018-12-19
- 1.0.0-rc.5 — 2018-11-28
- 1.0.0 — 2018-10-31
- 1.0.0-rc.3 — 2018-10-26
- 1.0.0-rc.2 — 2018-10-19
- 1.0.0-rc.1 — 2018-09-20
- 1.0.0-rc.0 — 2018-09-18

## README

# expo-firebase-database

> expo-firebase is still in RC and therefore subject to breaking changings. Be sure to run `yarn upgrade` and `cd ios; pod install` when upgrading.

`expo-firebase-database` provides a json based cloud data store that is synchronized in real-time.

[**Full documentation**](https://rnfirebase.io/docs/master/database/reference/database)

## Installation

Now, you need to install the package from `npm` registry.

`npm install expo-firebase-database` or `yarn add expo-firebase-database`

### iOS

#### Cocoapods

If you're using Cocoapods, add the dependency to your `Podfile`:

```ruby
pod 'EXFirebaseDatabase', path: '../node_modules/expo-firebase-database/ios'
```

and run `pod install`.

### Android

1.  Append the following lines to `android/settings.gradle`:

    ```gradle
    include ':expo-firebase-database'
    project(':expo-firebase-database').projectDir = new File(rootProject.projectDir, '../node_modules/expo-firebase-database/android')
    ```

    and if not already included

    ```gradle
    include ':expo-core'
    project(':expo-core').projectDir = new File(rootProject.projectDir, '../node_modules/expo-core/android')

    include ':expo-firebase-app'
    project(':expo-firebase-app').projectDir = new File(rootProject.projectDir, '../node_modules/expo-firebase-app/android')
    ```

2.  Insert the following lines inside the dependencies block in `android/app/build.gradle`:
    ```gradle
    api project(':expo-firebase-database')
    ```
    and if not already included
    ```gradle
    api project(':expo-core')
    api project(':expo-firebase-app')
    ```
3.  Include the module in your expo packages: `./android/app/src/main/java/host/exp/exponent/MainActivity.java`

    ```java
    /*
    * At the top of the file.
    * This is automatically imported with Android Studio, but if you are in any other editor you will need to manually import the module.
    */
    import expo.modules.firebase.app.FirebaseAppPackage; // This should be here for all Expo Firebase features.
    import expo.modules.firebase.database.FirebaseDatabasePackage;

    // Later in the file...

    @Override
    public List<Package> expoPackages() {
      // Here you can add your own packages.
      return Arrays.<Package>asList(
        new FirebaseAppPackage(), // This should be here for all Expo Firebase features.
        new FirebaseDatabasePackage() // Include this.
      );
    }
    ```

## Usage

```javascript
import React from 'react';
import { Button } from 'react-native';
import firebase from 'expo-firebase-app';
// API can be accessed with: firebase.database();

export default class PonyView extends React.Component {
  async componentDidMount() {
    const ref = firebase.database().ref('posts');
    ref.on('value', snapshot => {
      const val = snapshot.val();
      console.log(val);
    });
  }

  render() {
    return <View />;
  }
}
```

---
_Source: https://npm.io/package/expo-firebase-database · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
