react-nativeindexeddb

Does React Native support Indexed DB?


This question was asked on GitHub, with the answer being "Hey, have you heard of this website Stack Overflow? You should ask the question there!".

So here I am, asking a question!

Does React Native support Indexed DB?

When refactoring an existing web-application to support react-native, does one have to forgo Indexed DB support? Or, does Indexed DB work out of the box?

What is the reason for the answer to the above question? Does Indexed DB not work simply because we're not in a browser and React Native doesn't currently implement that API? Can we polyfill Indexed DB in React Native? Or, should we turn to alternative persistence methods for this platform?

I am asking this as a technical lead, wanting to know whether or not react-native is going to be an easy or difficult transition for our team.


Solution

  • No, as of now React Native doesn't support IndexedDB.

    For persistent storage in React Native the options are:

    AsyncStorage: The easiest way to store objects, provides Key-value based asynchronous APIs to store data. Only provides basic get-put APIs, not suitable for search queries.

    Realm: Fully fledged document oriented mobile database with the capacity for complex queries. Has both Pro and free open source editions. Best option for developing offline applications synchronised with the server.