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

470
Vistas
Should one use local storage to persist and reload redux state and JWT across browser restarts?

Is there any rule regarding when to use local storage or not to store state information if I have redux?

For example if I have some online form, then

Q1. should I have its state (currently filled values) persisted to localstorage say when user closes tab or browser, so that I can reload the state in redux from localstorage when user revisits the webpage? Is there any well know / documented security consideration for storing redux state in local storage?

Q2. Or should I always send last saved redux state from the server (and not save and load from localstorage) when user visits the website first time after opening the browser. If that is the case

Q3. If the answer to Q2 is YES, then what about JWT? Should we store JWT in localstorage avoiding forcing user to re-login?

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

0

Q1

In terms of OAuth Best Current Practice I would avoid storing anything like this in local storage:

  • Credit card numbers
  • Passwords
  • Access tokens
  • Personally identifiable information, eg name, email

Use browser storage for simple data such as the application path before an OAuth redirect, or simple boolean preferences. Prefer session storage over local storage, unless you need settings across multiple browser tabs.

Q2

Using the server is safest for anything sensitive, so it is worth investing in an API driven save and load option.

Q3

Avoid JWTs in local storage, since there are more attack vectors that could result in stolen data. If you are migrating from this model then start by storing a refresh token in an encrypted HTTP Only SameSite=strict cookie, and store access tokens only in memory.

This will enable you to avoid logins on page reloads or when the user opens a new browser tab, and is easy to implement by routing token requests via a utility API. You could then go further to take access tokens out of the browser completely. See the SPA Best Practices article for further related details.

about 4 years ago · Juan Pablo Isaza Denunciar

0

It depends.

Q1. If it's non-updating data and you don't need to make request to backend for it. You can use localstorage.

Security Issue with localstorage is that user can access it and alter or delete the data. In that case you again need to hit your api for data.

Q2. If the data is updating (eg - posts,likes in blog app). Then you need to make a request to server to fetch the latest data.

Q3. Yes, mostly jwt is stored in localStorage which avoid user to re-login. If the user try to alter the jwt, the backend has methods to check it. read How jwt works

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