Samuel Shan
Samuel Shan

Reputation: 343

How can I access local database on react native?

We often access a local sqlite database when we developing an app. What is the counterpart in react native? Do I have to use AsyncStorage to store data without a native module?

Upvotes: 33

Views: 55940

Answers (4)

Colin Ramsay
Colin Ramsay

Reputation: 16466

Updated answer: there's now a fledgling SQLite wrapper available:

https://github.com/andpor/react-native-sqlite-storage

Previously:

This comment on Hacker News indicates that there's nothing available right now:

There is currently no native module for SQLite, but you can build one if you want. :-D http://facebook.github.io/react-native/docs/nativemodulesios.html

We use a key-value store for most of our client-side persistence: http://facebook.github.io/react-native/docs/asyncstorage.html

It's by Eric Vicenti who seems to work at Facebook and contribute to React Native, so pretty authoritative.

Upvotes: 21

Zhanibek Bekbossyn
Zhanibek Bekbossyn

Reputation: 51

Embedded persistent or in memory database for react-native https://github.com/smartdemocracy/react-native-local-mongodb

It's have Performance statistics

  • Insert: 10,680 ops/s
  • Find: 43,290 ops/s
  • Update: 8,000 ops/s
  • Remove: 11,750 ops/s

Upvotes: 5

Waqas Ahmed
Waqas Ahmed

Reputation: 1411

Realm React Native enables you to efficiently write your app’s model layer in a safe, persisted and fast way. Here’s what it looks like: See Realm React Native and Docs For Realm

Upvotes: 12

Moonwalker
Moonwalker

Reputation: 3802

Full feature SQLite Plugin for React Native is available here:

https://github.com/andpor/react-native-sqlite-storage

Version 2.1.0 supports both iOS and Android and the fmk has both plain JS callback and Promise based interfaces.

Upvotes: 14

Related Questions