markdown guide
 

Hello, I assume you are using tokens as it's a stateless app, so you might like to give js-cookie a try, seems to be a better solution than using local storage.
You can use it as follows

import Cookie from "js-cookie"

const token =  Cookie.get("token") ? Cookie.get("token") : null;

//to set a cookie
Cookie.set("token", token);

//refer the js-cookie documentation for more options

 

Don't store it in local storage, that's definitely not secure. Cookies too aren't great; all those options are physically stored on the client.

The answer to how you should secure it very much depends upon the type of your app? Does it have a server back-end, or is it just a SPA with API end-points?

Generally the guideline seems to be to not to store the token at all, but get a one-use token each page load that stays in memory.

Take a look at some info Auth0 provide for guidelines that links through to some OIDC patterns for securely using tokens in different types of web apps.

auth0.com/docs/security/store-tokens

 

You just need to have it handy as long as you use https

Classic DEV Post from May 13

How to approach solving a challenge during a coding interview

Like many things in life, mastery requires practice and the coding interview is n...

Ali Rizvi profile image
MERN Stack Developer, with the passion to develop apps that can make this world better. "Whenever I get bored, I call API's"