DEV Community

Discussion on: The Ultimate Guide to JWT client side auth (Stop using local storage!!!)

Collapse
 
bahdcoder profile image
Kati Frantz

No dumb questions here Andrei, thanks for asking. This is just for convenience. You can tell the client when it expires, which means the client knows when to refresh, and does not wait for an unexpected expiry before refreshing. Like @nishchal mentioned, you can always wait for the backend to return a 401, and then either automatically logout the user and redirect to the sign in page, or refresh the token and keep the user's session.