https://github.com/lc-2025/storage-manager
A browser storage library
https://github.com/lc-2025/storage-manager
github-actions javascript jest-testing localstorage-api npm-packages open-source react-hooks sessionstorage-api storage-manager typescript web-storage
Last synced: 2 months ago
JSON representation
A browser storage library
- Host: GitHub
- URL: https://github.com/lc-2025/storage-manager
- Owner: lc-2025
- License: mit
- Created: 2025-09-28T13:53:07.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-11-06T13:52:17.000Z (7 months ago)
- Last Synced: 2025-11-17T05:23:34.221Z (7 months ago)
- Topics: github-actions, javascript, jest-testing, localstorage-api, npm-packages, open-source, react-hooks, sessionstorage-api, storage-manager, typescript, web-storage
- Language: TypeScript
- Homepage: https://npmjs.com/package/@lc-2025/storage-manager
- Size: 400 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Storage Manager
A browser storage library.
[](https://github.com/lc-2025/storage-manager/actions/workflows/ci.yml) [](https://github.com/lc-2025/storage-manager/actions/workflows/cd.yml)
## About
An out-of-the-box `Storage API` _NPM_ package to securely manage browser storage actions. Performs the proper support checks and triggers each action according to the browser specifications.
## Features
- Both Local than Session objects support
- Usable as a standalone utility as well as a _React_ hook
## Stack
- **Languages**: JavaScript, Typescript, YAML, Bash
- **Environments**: DOM
- **Libraries**: Testing Library
- **Frameworks**: Jest
- **Linters/Plugins**: ESLint, Prettier
- **Compilers**: Babel, TypeScript
- **Testing**: Jest, Testing Library
- **Versioning**: GitHub, Husky
- **Continuous-Integration/Delivery**: GitHub Actions
- **Deployment**: NPM Registry
## Getting Started
The package production version is available on _NPM_ at [https://npmjs.com/package/@lc-2025/storage-manager](https://npmjs.com/package/@lc-2025/storage-manager).
For any contribution, maintanance and/or trial needs, please refer to the following specifications.
### Installation
On terminal, from project root:
```bash
npm i @lc-2025/storage-manager
```
### Usage
- As a _React_ hook:
```jsx
// MyComponent.{jsx|tsx}
import { useStorage } from '@lc-2025/storage-manager';
const myComponent = () => {
// As `localStorage`
const { setStorage } = useStorage();
const handleSomething = () => {
//...
setStorage('myItem', '123');
//...
}
return (
//...
);
}
```
- As a standalone utility (`sessionStorage`):
```jsx
// myFeature.{js|ts}
const { getStorage, deleteStorages } = useStorage('session');
const myFunction = () => {
//...
const value = getStorage('myItem');
//...
deleteStorages(['myItem']);
};
```
### API
- **Type**: `[local|session]` (default: `local`)
Defines the `Storage API` object to be used
```js
// Use `sessionStorage` API
const { setStorage } = useStorage('session');
```
- **Get**
Invokes the `Storage API` `getItem` method
```ts
getStorage(item: string): string | null
```
- **Set**
Invokes the `Storage API` `setItem` method
```ts
setStorage(item: string, value: string): void
```
- **Delete**
Invokes the `Storage API` `removeItem` method on a provided collection
```ts
deleteStorages(items: Array): void
```
## Contributing
### Setting Up
On terminal, from project root:
- To install dependencies
```bash
npm run install
```
- To lint the sources
```bash
npm run lint
```
- To build the production version
```bash
npm run build
```
### Tests
#### Unit
On terminal, from project root:
- To run the unit tests in `development` mode
```bash
npm run test
```
- To run the tests in `testing` mode (staging or content-integration/delivery environments)
```bash
npm run test:ci
```
### Deploy
_Storage Manager_ is integrated and delivered to production via _GitHub Actions_ workflows pipeline, where the package is being set up, tested and built.
Then the artifacts are deployed on _NPM_ registry available at [https://npmjs.com/package/@lc-2025/storage-manager](https://npmjs.com/package/@lc-2025/storage-manager).
- To deploy the production version
```bash
npm run deploy
```
Please read more about required best practices on the specific [contributing reference document](./.github/CONTRIBUTING.md).