GitHub Storage Handler Ts is a utility for managing localStorage
in React applications using TypeScript hosted on GitHub Pages. It provides a simple interface to handle storage operations with path-based organization, making it ideal for use in Redux slices and React context.
View GitHub repository
- Easy management of
localStorage
for GitHub Pages. - Path-based storage organization.
- Supports storing and retrieving strings, objects, numbers, and booleans.
- Integrates seamlessly with Redux slices (GitHubStorageHandlerTs) and React context (GitHubStorageHandlersTs).
Install the package using npm:
npm install github-localstorage-handler-ts
import {GitHubStorageHandlerTs} from 'github-localstorage-handler-ts';
import {GitHubStorageHandlersTs} from 'github-localstorage-handler-ts';
GitHubStorageHandlerTs
can be used within a Redux slice to manage state persistence:
// In your Redux slice
const storageHandler:GitHubStorageHandlerTs = new GitHubStorageHandlerTs('reduxPath');
// Save state to localStorage
storageHandler.setObject(state);
// Load state from localStorage
const persistedState = storageHandler.getObject({});
GitHubStorageHandlersTs
is ideal for managing multiple paths in a React context:
// In your React context provider
const handlers = new GitHubStorageHandlersTs('contextPath1', 'contextPath2');
// Set and get items using specific paths
handlers.setItem('contextPath1', 'value1');
const value1:string|null = handlers.getItem('contextPath1');
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the ISC License.