Secure-Storage icon indicating copy to clipboard operation
Secure-Storage copied to clipboard

How to import the module?

Open Louies89 opened this issue 4 years ago • 6 comments

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.

Louies89 avatar Jun 25 '20 10:06 Louies89

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

goblinrum avatar Jun 28 '20 20:06 goblinrum

import SecureStorage from 'secure-web-storage'; is not working throwing error like localstorage is not defined and SecureStorage is not a class

Louies89 avatar Jun 29 '20 07:06 Louies89

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.

goblinrum avatar Jun 29 '20 13:06 goblinrum

I am using SSR, so that is creating trouble.

Louies89 avatar Jun 29 '20 16:06 Louies89

if you are using next js you could do a server check or dynamically import the component in which you've imported the library.

khoa-gigantecmedia avatar Jul 20 '21 03:07 khoa-gigantecmedia

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?

migmolrod avatar Sep 23 '22 16:09 migmolrod