Search⌘ K

The localStorage API

Explore how to manage persistent data in front-end web apps using the localStorage API. Understand how to represent tables as entity tables, serialize them with JSON, and store them effectively in localStorage for practical data persistence in JavaScript.

We'll cover the following...

In most applications, we have some form of data management that presents data in tables so that table rows correspond to objects and the table schema corresponds to the objects’ type. When building a front-end web application with JS, the simplest way to get persistent data storage is to use the localStorage API.

However, while the localStorage API provides a simple key-value database it doesn’t support database tables. So, the question is, how can we store and retrieve tables with localStorage? To do this, we’ll need to learn to represent database tables in the form of entity tables. Then, we’ll learn to store those tables in localStorage.

Entity tables

JSON defines the following concise syntax for JavaScript array literals (lists) and object literals (maps):

...