https://github.com/importantimport/ezss
🔒️ Easier alternative of react-secure-storage.
https://github.com/importantimport/ezss
Last synced: about 1 month ago
JSON representation
🔒️ Easier alternative of react-secure-storage.
- Host: GitHub
- URL: https://github.com/importantimport/ezss
- Owner: importantimport
- License: mit
- Created: 2023-10-13T11:31:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T12:45:08.000Z (over 2 years ago)
- Last Synced: 2025-12-15T02:15:58.774Z (6 months ago)
- Language: TypeScript
- Homepage: https://npm.im/ezss
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EZSS [](https://npmjs.com/package/ezss) [](https://pkg-size.dev/ezss) [](https://pkg-size.dev/ezss)
Easier alternative of `react-secure-storage`.
## Why
The `react-secure-storage` code is unnecessarily complex and doesn't support custom data types.
EZSS only implements its internal `EncryptionService` class so that you can use it with the libraries you want. (e.g. `@mantine/hooks`)
## Install
```bash
pnpm add ezss
# yarn add ezss
# npm i ezss
```
## Usage Examples
> do you have other examples? PR's welcome!
###### @mantine/hooks - useLocalStorage
```ts
import { useLocalStorage } from '@mantine/hooks'
import encryption from 'ezss' // A
// import { EncryptionService } from 'ezss' // B
// const encryption = new EncryptionService() // B
export const useSecureLocalStorage =
(props: Parameters>[0]) =>
useLocalStorage({
...props,
serialize: value => encryption.encrypt(JSON.stringify(value)),
deserialize: value => {
if (value) {
try {
return JSON.parse(encryption.decrypt(value))
} catch {
return encryption.decrypt(value)
}
} else return value
},
})
```
## License
Licensed under the [MIT](LICENSE).