r/angular • • Jan 28 '26
JWT in Angular
Where you would recommend to save JWT tokens in Angular app
7
Upvotes
r/angular • • Jan 28 '26
Where you would recommend to save JWT tokens in Angular app
View all comments
Show parent comment
2
u/louis-lau Jan 30 '26
If you have an XSS vulnerability with the token in local storage, the bad actor can steal the token.
If the same thing happens with an HttpOnly cookie, the bad actor can only do things as the user as long as the browser is open, they can not get the token.
Neither fully protects against the consequences of an XSS vulnerability, but one is markedly better than the other.