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
- The
localStorageAPI only works client side, and therefore does not work in TypeScript Server functions.