@procore/web-sdk-storage
v0.1.0
Published
Procore Web Platform Storage
Downloads
139
Maintainers
Keywords
Readme
Web Platform Storage
A browser storage solution for Procore front-end applications, providing a standardized interface for interacting with local and session storage.
Installation
You can install @procore/web-sdk-storage
via yarn:
yarn add @procore/web-sdk-storage
Features
- Type-safe access to
localStorage
andsessionStorage
. - Accepts
react-query
-style keys for cleaner storage keys.
Usage
Local Storage
import { storage } from '@procore/web-sdk-storage';
const itemToSave: Item = {
some: 'data',
};
const itemKey = ['items', { companyId: 1, projectId: 2, itemId: 3 }];
storage.local.setItem(itemKey, itemToSave);
const savedItem = storage.local.getItem<Item>(itemKey);
storage.local.deleteItem(itemKey);
Session Storage
import { storage } from '@procore/web-sdk-storage';
const itemToSave: Item = {
some: 'data',
};
const itemKey = ['items', { companyId: 1, projectId: 2, itemId: 3 }];
storage.session.setItem(itemKey, itemToSave);
const savedItem = storage.session.getItem<Item>(itemKey);
storage.session.deleteItem(itemKey);