expo-storage
TypeScript icon, indicating that this package has built-in type declarations

48.1.0 • Public • Published

expo-storage

Simple way to store persistent data, which does not have size limitations of react-native async-storage

Usage

Add to project

yarn add expo-storage

or

expo install expo-storage

Storage

Just like async-storage, expo-storage works with string values and can only store string data, so in order to store object data you need to serialize it first. For data that can be serialized to JSON you can use JSON.stringify() when saving the data and JSON.parse() when loading the data.

import { Storage } from 'expo-storage'

To store item:

   await Storage.setItem({
    key: `${photo.id}`,
    value: JSON.stringify(myJsonObject)
  })

To get item:

  const item = JSON.parse(
    await Storage.getItem({ key: `${item.id}` })
  )

To delete a record by key:

  await Storage.removeItem({ key: `${item.id}` })  

To get all keys available in storage:

  const keys = await Storage.getAllKeys()  

Sample projects

https://github.com/echowaves/WiSaw

https://www.wisaw.com/

Package Sidebar

Install

npm i expo-storage

Weekly Downloads

251

Version

48.1.0

License

MIT

Unpacked Size

8.07 kB

Total Files

8

Last publish

Collaborators

  • echowaves