What is Local Storage?

Local storage is built right into the web browser, and it exists as a property on the object window: Window.localStorage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).

Storage Space Size

The amount of available local storage space in browsers is based on the user’s browser and the storage amount available on their device.

Common Uses

  • Save the most recent searches the user has made on your site.
  • Save data entered into a form, so if the user leaves and comes back, they don’t need to start over.
  • Save user’s login names –not passwords– that have been used in the past to save the user from typing.
  • Store user’s preferences without having to reset them each time they reopen your app.

Not Secure!

Local storage is not secure, as any JavaScript executing on a page has access to local storage.

What’s Being Stored?

Local storage only stores string data! Local storage is a collection of name/value pairs, where the value of a local storage property is always a string. The value can’t be an array or Boolean or a binary file like a JPEG or a movie.
If you need to store other data types like objects or arrays in local storage, you need to convert them to a string using JSON.Stringify().

Don’t Store Too Much!

When a page loads, browsers load the data in local storage synchronously. The browser can’t do anything else while the local storage data loads. If there is a lot of data to store, your users may experience a delay during that time. Consider the amount of data you wish to store carefully!