Local data storage can be used by a PWA to store or cache content on the user's device for display or later use and is an important tool when developing applications for offline use.
There are two types of local data storage available:
- Local Storage, a key-value system for storing strings
- IndexedDB, a simple database system for storing multiple strings with a shared index
It is possible to store other data types by transforming them into a string. Objects and other complex data can be stored using JSON.stringify()
and retrieved using JSON.parse()
.
For more information, see the MDN documentation.