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