react check if local storage item exists code example Example: check if localstorage key exists if (localStorage.getItem("username") === null) { //... }