Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access local database on react native?

Tags:

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?

like image 675
Samuel Shan Avatar asked Mar 28 '15 05:03

Samuel Shan


People also ask

How does react native connect to database?

To install the "app" module, view the Getting Started documentation. # Install & setup the app module yarn add @react-native-firebase/app # Install the database module yarn add @react-native-firebase/database # If you're developing your app using iOS, run this command cd ios/ && pod install && cd ..

Can we use SQL database in react native?

React Native is also compatible with server-side databases. The list includes SQL databases, such as: MySQL.


2 Answers

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.

like image 58
Colin Ramsay Avatar answered Sep 18 '22 00:09

Colin Ramsay


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.

like image 29
Moonwalker Avatar answered Sep 18 '22 00:09

Moonwalker