how to check whether key is stored in localstorage react code example Example: check if localstorage key exists if (localStorage.getItem("username") === null) { //... }