0.1.0 • Published 12 months ago

@procore/web-sdk-storage v0.1.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
12 months ago

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 and sessionStorage.
  • Accepts react-query-style keys for cleaner storage keys.

Usage

Local Storage

MDN Documentation

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

MDN Documentation

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);

Support

#team-ui-foundations

0.1.0

12 months ago