Secure-Storage
Secure-Storage copied to clipboard
How to import the module?
Hi @Mike96Angelo , Thanks for the library. But I am unable to make it work, as I am not able to import it in any way.
Please provide a working code example.
Hi @Mike96Angelo , Thanks for the library. But I am unable to make it work, as I am not able to import it in any way.
Please provide a working code example.
import SecureStorage from 'secure-web-storage'; very intuitive considering the naming schemes
import SecureStorage from 'secure-web-storage'; is not working throwing error like localstorage is not defined and SecureStorage is not a class
is not working throwing error like localstorage is not defined
Are you working in a JS environment that supports localStorage? You can't use localStorage in a browser that doesn't support storage or in a server environment like node.
I am using SSR, so that is creating trouble.
if you are using next js you could do a server check or dynamically import the component in which you've imported the library.
In my case (Angular, using Typescript), I can't import it like that. It throws this error:
TS7016: Could not find a declaration file for module 'secure-web-storage'.
'./node_modules/secure-web-storage/secure-storage.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/secure-web-storage` if it exists
or add a new declaration (.d.ts) file containing `declare module 'secure-web-storage';`
Tried npm i --save-dev @types/secure-web-storage
but NPM can't find the package, apparently. So where and how do I add a new type declaration?