Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Best pratice to store an API token in the front

Hello,

I specify that, even if I know VueJS a bit, I have very small knowledge about security with VueJS. For me I have all to learn about security.

What's the best pratice to store an API token in the front ?

I have read several articles which all say that the best pratice is to store it in the localStorage or in the sessionStorage.

But I'm not sure it's really a best pratice.

I thought about storing it in the VueJS store.

But in both cases the value is readable via some browser devtools. And I'm not sure it's a good idea to let anyone be able to read the token.

What's your opinion about the storage of the token ?

Thanks for your answer.

V

0 likes
4 replies
martinbean's avatar

@vincent15000 It’s not “secure” to store a credential such as an API token in plaintext anywhere on the client. This is why Taylor created Sanctum for authenticating JavaScript-based applications.

1 like

Please or to participate in this conversation.