Recipes
Data & Functions
Use browser localStorage

Use browser localStorage

Problem

You would like to store and retrieve data client side in the browser’s localStorage (opens in a new tab).

Solution

Use the localStorage API inside a TypeScript Client function:

Code example

localStorage.setItem("foo", "bar")
localStorage.getItem("foo") // => "bar"

Discussion

See also