how to check is the key of a localstorage is emopty

JavaScript
if (localStorage.getItem("username") === null) {
  //...
}if (localStorage.getItem("username") === null) {
  //...
}

Source

Also in JavaScript: