Home

Awesome

Overview

Example of a simple React Native app on Android that uses Couchbase Lite as embedded datastore for offline data storage and Sync Gateway/Couchbase Server for remote data sync. The app uses a reference implementation of React Native Module that exposes a subset of couchbase lite APIs.

LICENSE: The source code for the app is Apache-licensed, as specified in LICENSE. However, the usage of Couchbase Lite will be guided by the terms and conditions specified in Couchbase's Enterprise or Community License agreements.

This repo contains three versions of the app, each building on the previous version of the app and demonstrating a specific addional functionality of Couchbase Lite. Each version of the app includes an iOS version and a corrresponding Android version.

Demo

Shown below is a demonstration of data sync capability between iOS and Android versions of the app

Folder Overview

standalone

This version of app demonstrates basic database and document CRUD operations using Couhbase Lite as a standalone, embedded database within your mobile app. A document is created and stored in a "user" Couchbase Lite database.

For details, refer to the README in the "standalone" folder of the repo.

query

This version of app extends the "standalone" version of the app and demonstrates basic query and full-text-search operations against Couhbase Lite database. In addition to the "user" database, this version of the app is bundled with a second "university" database pre-seeded with documents against which queries are issued.

For details, refer to the README in the "query" folder of the repo.

sync

This version of app extends the "query" version of the app and demonstrates basic database sync functionality. The app supports bi-directional sync with a remote Couchbase Server database through a Sync Gateway.

For details, refer to the README in the "sync" folder of the repo.

Getting Started

Each version of the app includes an iOS version and a corrresponding Android version. Follow the corresponding instructions based on the version you are building.

Android Version

The instructions apply to standalone, query and sync versions of the app.

Prerequisites

Build

git clone https://github.com/couchbaselabs/userprofile-couchbase-mobile-reactnative
cd  /path/to/cloned-repo/standalone

 yarn add https://github.com/couchbaselabs/couchbase-lite-react-native-module

 npm install

The module does not come bundled with the couchbase lite framework. You will have to include the appropriately licensed Couchbase Lite Android library as dependency within your app.

The React native reference module requires minimal version of Couchbase Lite v3.0.0.

In your 'app' level build.gradle file, add your library file path

 dependencies {
    implementation 'com.couchbase.lite:couchbase-lite-android:${version}'
 }

In your 'project' level build.gradle file, add your library file path.

 buildscript {
    ...
    ext {
        ...
        // Add this line
        cblVersion = 'com.couchbase.lite:couchbase-lite-android:${version}'
        ...
        }
    ...
}

Running the App

Build and run the app per instructions in Getting Started Guide. You can run the app direcly from Android Studio or from command line.

Don't forget to start the Metro bundler before running your app!

npx react-native start

iOS Version

The instructions apply to standalone, query and sync versions of the app

Prerequisites

Build

git clone https://github.com/couchbaselabs/userprofile-couchbase-mobile-reactnative
cd  /path/to/cloned-repo/standalone

 yarn add https://github.com/couchbaselabs/couchbase-lite-react-native-module

 npm install
cd ios
pod install

open userprofiledemo.xcworkspace

Running the App

Build and run the app per instructions in Getting Started Guide. You can run the app direcly from Xcode or from command line.

Don't forget to start the Metro bundler before running your app!

npx react-native start