angulargithubnpmweb-storage

Is it safe to use browser window.sessionStorage or ng libraries like ngx-webstorage in Angular 4


I am trying to find the answers for, Which is best suitable way to use Session Storage in Angular 4 or later version like 5.

Currently project is using HTML5 window localStorage and sessionStorage. Should I use third party libraries like angular-2-local-storage or ngx-webstorage.

If yes, which one is best to use / more efficient compared to others ?

Please suggest.


Solution

  • It should be noted that the use of localStorage (or sessionStorage) is absolutely neither safe nor proven. Depending on the data you're storing, you could be creating significant vulnerabilities and/or liabilities. If your client is expecting security, build a proper back-end.

    If you're looking for an opinion on the two libraries I would go with ngx-store, as the angular2-localstorage library is no longer maintained.

    The decision to use a library vs. the native window.localStorage call depends, or course, on the specifics of your situation.