Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

316
Vistas
Clear tokens in Local Storage when all tabs or Browser is closed in React

I want to remove the user Authentication when the application has been loaded in multiple tabs. Once all the tabs that had the application loaded are closed or the entire browser is closed, I want to remove the token stored in local storage. When a user again opens a new tab and tries to enter the application, it should redirect to the login page. How can this be achieved in react, like how to detect that all tabs that have that application loaded closed?

Note -- I want to remove the token and display the login page only when all the tabs are closed or the browser is closed.

For an Instance, If the application has been loaded in 5 tabs, on the closing of all 5 tabs only I need to remove the token.

Is it possible to use a Broadcast channel to achieve this? but I am not sure how to implement them

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Did you try this way?

  1. Count every tab open and save it to localStorage
  2. Handle event unload and update localStorage if openedTab === 0 then clear it in unload event
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda