Skip to content

Session Storage like module for react native for temporary session bound storage.

License

Notifications You must be signed in to change notification settings

JairajJangle/react-native-session-storage

Repository files navigation

react-native-session-storage

Session Storage like module for React Native for session-bound storage.

This module is NOT an alternative for Async Storage which is meant for persistent storage. Instead, this module provides a "volatile" storage which gets cleared when the app is re-opened.

Installation

With npm:

npm install react-native-session-storage

With yarn:

yarn add react-native-session-storage

With Expo CLI:

expo install react-native-session-storage

Usage

Importing

import SessionStorage from 'react-native-session-storage';

Storing data

The value can be of any type.

SessionStorage.setItem('@storage_key', value);

Reading data

The return value is of the type of the value which was stored using setItem(...)

const data = SessionStorage.getItem('@storage_key');

Removing data

SessionStorage.removeItem('@storage_key');

Clearing all keys

SessionStorage.clear();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library