check if key has value in localstorage code example Example: check if localstorage key exists if (localStorage.getItem("username") === null) { //... }