score:0

You can check if the item exists in the local storage and redirect if not like so :

   if (localStorage.getItem("token") === null) {
  //your redirection code here 
}

Related Query

More Query from same tag