React Forage
LocalForage Hooks and Providers for React.
Installation
Install the module with your favorite package manager:
Terminal
npm install react-forage
Examples
In the following example, state data will be stored in IndexedDB. You can switch to the Application panel in the browser console (press F12
). In IndexedDB, you can see a database named react-forage-website
and a data table named examples
.
Store state into IndexedDB
Refresh this page and you will get the state from IndexedDB.
Store complex types of data
The useLocalForageState
hook will do the serialization and deserialization
work automatically.
a-e-i-o-u
Custom serialization and deserialization functions
You may not need the default JSON.stringify
or JSON.parse
to serialize
string.
Drops store of the current instance
Please open the console to view the database changes of IndexedDB. When invoked with no arguments, it drops the “store” of the current instance.