Skip to content
SQLCipher Native Plugin for React Native for iOS and Android.
C C# Java Objective-C JavaScript Python Ruby
Branch: master
Clone or download
Pull request Compare This branch is 18 commits ahead, 60 commits behind craftzdog:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android
ios
src
test
windows
.gitattributes
.gitignore
.npmignore
.watchmanconfig
CHANGELOG.md
LICENSE
README.md
index.js
package.json
rn-cli.config.js

README.md

React Native SQLCipher 2

SQLCipher Native Plugin for React Native for Android/iOS. This plugin provides a WebSQL-compatible API to store data in a react native app, by using a SQLCipher database on the native side.

Forked from React native SQlite 2

Getting started

$ npm install react-native-sqlcipher-2 --save

Mostly automatic installation

$ react-native link react-native-sqlcipher-2

Additional step for iOS

Add the following to your Podfile

pod 'SQLCipher'

Usage

import SQLite, { encodeName } from 'react-native-sqlcipher-2';

const db = SQLite.openDatabase(encodeName('test.db', 'testpassword'), '1.0', '', 1);
db.transaction(function (txn) {
  txn.executeSql('DROP TABLE IF EXISTS Users', []);
  txn.executeSql('CREATE TABLE IF NOT EXISTS Users(user_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(30))', []);
  txn.executeSql('INSERT INTO Users (name) VALUES (:name)', ['nora']);
  txn.executeSql('INSERT INTO Users (name) VALUES (:name)', ['takuya']);
  txn.executeSql('SELECT * FROM `users`', [], function (tx, res) {
    for (let i = 0; i < res.rows.length; ++i) {
      console.log('item:', res.rows.item(i));
    }
  });
});

There is a test app in the test directory.

Using with PouchDB

It can be used with pouchdb-adapter-react-native-sqlite.

import PouchDB from 'pouchdb-react-native'
import SQLite, { encodeName } from 'react-native-sqlcipher-2'
import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite'

const SQLiteAdapter = SQLiteAdapterFactory(SQLite)
PouchDB.plugin(SQLiteAdapter)
var db = new PouchDB(encodeName('test', 'testpassword'), { adapter: 'react-native-sqlite' })
You can’t perform that action at this time.