@procore/web-sdk-storage
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Web Platform Storage

A browser storage solution for Procore front-end applications, providing a standardized interface for interacting with localStorage and sessionStorage.

Installation

Install 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

import { storage } from '@procore/web-sdk-storage';

const itemToSave: Item = {
  some: 'data',
};
const itemKey = ['items', { companyId: 1, projectId: 2, itemId: 3 }];

// set item in local storage
storage.local.setItem(itemKey, itemToSave);

// set item on session
storage.session.setItem(itemKey, itemToSave);

const defaultValue = {
  some: 'default',
};

// get item from local storage
const savedItem = storage.local.getItem<Item>(itemKey, defaultValue);

// get item from session storage
const savedItem = storage.session.getItem<Item>(itemKey, defaultValue);

API Reference

Both storage.local and storage.session share the same set of methods for interacting with localStorage and sessionStorage, respectively.

Methods

  • setItem(key, value)

    Stores a value under the specified key.

    storage.local.setItem(key, value);
    storage.session.setItem(key, value);
  • getItem<T>(key, defaultValue = null)

    Retrieves the value associated with the specified key.

    const value = storage.local.getItem<T>(key, defaultValue);
    const value = storage.session.getItem<T>(key, defaultValue);
  • deleteItem(key)

    Removes the item associated with the specified key.

    storage.local.deleteItem(key);
    storage.session.deleteItem(key);
  • clear()

    Clears all items from the storage.

    storage.local.clear();
    storage.session.clear();

Parameters

  • key: Can be a string or an array (e.g., React Query-style key) that uniquely identifies the storage item.
  • value: The data you want to store, which can be any serializable JavaScript object.
  • defaultValue: The fallback object to return if the key is not found or has an error. Will default to null.

Support

#team-ui-foundations

Readme

Keywords

none

Package Sidebar

Install

npm i @procore/web-sdk-storage

Weekly Downloads

99

Version

0.2.0

License

SEE LICENSE IN LICENSE

Unpacked Size

15.7 kB

Total Files

10

Last publish

Collaborators

  • squidbeaks
  • swati.jadhav
  • tejeshwar
  • mohitsharma97
  • andreszorrilla-procore
  • magdyyxx
  • charan_procore
  • aly-el-kerdany
  • s_kudryk
  • adarsh.gautam
  • vishal-procore
  • kalyani.gosavi
  • amit.gurav-contractor
  • worldofsatyaki
  • kuldeepsingh4556
  • karina.mendez-contractor
  • bikash.sahoo
  • rowan.ibrahim
  • vinayakaprabhu
  • saurasumprocore
  • conner-procore
  • chaitra-m-15
  • vsobol-c
  • abhishekkumar123
  • jasaswini
  • aleh.haurylenia-contractor
  • kellikearns
  • viktoriia_azarovska
  • fabriciobd
  • youssefamer
  • brockpcor
  • kani-procore
  • antonyayoub
  • ashish.sharma2024
  • glidenor
  • daniel-pierre-procore
  • amitk030
  • mathenes_procore
  • vinoth.kuppusamy
  • mariia.solodovnik
  • sflang-procore
  • cassianomatos-procore
  • alan.facchini-contractor
  • zayter
  • bohdan-horai-procore
  • nigeld-procore
  • samad.virani
  • fernandocamilotti
  • connie-feng-procore
  • roger-procore
  • ganesh.raghupathy
  • yzhou2024
  • alyelashram_procore
  • melch-procore
  • peterknif
  • moaz-ashraf
  • attachi
  • a.elbadawei
  • hyogman
  • dmitri_wm
  • stephanie.brereton
  • procore-oss-user
  • stevenkang3
  • max.helmetag
  • codyrobertsprocore
  • miguel.garcia-procore
  • atoaima
  • mustafa-abdelrahman
  • elewando-procore
  • ahmed.ghorab
  • lnspatz914
  • richard.bunn
  • omar.wagdy
  • mona.khairbek
  • mbartlett413
  • cody_schindler_procore
  • yoasyo25
  • ritchlee
  • andersontr15
  • steven.hinkle
  • jamie-dugan-procore
  • hgouhierprocore
  • denzylbalram
  • sarah.freitas
  • alan.bresani
  • amyprocore
  • yoyis3000
  • elijah.procore
  • mike-arndt-procore
  • jnhoang1
  • pam-whisenhunt
  • shradha.khard
  • david-christensen-procore
  • javio-procore
  • chance.eakin.procore
  • gideon-procore
  • ihor.diachenko_procore
  • justinmwatts
  • tedyang
  • jyang-procore
  • pwhisenhunt-procore
  • fairchild
  • rodayna.ehab
  • neil1023
  • scottstern
  • brian.smith1
  • g2mitchell
  • dlameter-procore
  • kylepietz
  • abhijit-procore
  • lhuang325
  • jake-pitkin
  • erikthoreson
  • simona.iancu
  • decha-sanson
  • aberkowitz
  • asamay
  • mustafa-u-abdelrahman
  • rajatmenhdiratta
  • jacksonleach-procore
  • pmfrawley
  • phunguyen-pcor
  • tatsiana.clifton
  • deiab
  • srichaitanya.peddinti
  • kenny.foisy
  • matheusprocore
  • jgreene_procore
  • hectorthiele
  • etokarev
  • daniel.ferreira-contractor
  • dmccraw-procore
  • cyrille.bai
  • greg.sparks
  • fabiomelo513
  • phil.custer
  • bbreyel921
  • amir-iskander
  • neil.mckeeman
  • nickprocore
  • lzhou888
  • davidshure
  • stevenliprocore
  • ramysaid2
  • refaiepcn
  • jgentes
  • faraz.hanif
  • mostafaeltazy
  • agamaleldin
  • andrew.isaac
  • saranahal2
  • rodrigo.dejuana
  • kellen.stewart
  • bill-wagner
  • ezrasimeloff
  • jeffgiaquinto
  • gturkadze
  • sean.spearman.procore
  • kylemartinez-procore
  • roobo-romeski
  • andres-mendez-procore
  • gaurav.sharma.procore
  • tracy.otto
  • sarah.heredia
  • victorbendeck-pc
  • cbathgate
  • davidkangpro
  • kyle.liu
  • amin.jaipuri
  • grafffffff
  • mishaelowoyemi
  • evan.cerwonka.procore
  • ilya.dryha-contractor
  • varomir
  • yogevfine1
  • timofeee
  • matt.harris0223
  • winson.chu
  • andersonbispoprocore
  • scorgiat-procore
  • ladavarga
  • procore_halzy
  • enyaga
  • willpankonien
  • sateesh-kadiyala-procore
  • chris.berber
  • txin1
  • epalinprocore
  • mehrdad-panahandeh
  • tyler.wasden.procore
  • jeremy.lund
  • dineshkumar.jayak
  • ryanfuentesprocore
  • stajics
  • brocktillotsonprocore
  • kyle.williams
  • dtorres-procore
  • noor.ali
  • ari-procore
  • alanprocore
  • jl4ever
  • james.lawson
  • ajaykumar-procore
  • dennis.heckman
  • lalovar-procore
  • james.cleary
  • chadryder
  • devin.cunningham.procore
  • abhijit.patwardhan
  • lydiahara
  • sherylnapigkit
  • changprocore
  • apcarroll_procore
  • andy.mayer
  • bob.laskowski
  • vinaya-procore
  • kahliholmes
  • andrew.wheeler
  • leandro-proc
  • yadhu.prakash
  • jason-kaye
  • jesse.olsen
  • patrick.lardin
  • brad.urani
  • allenanle.procore
  • brookyboy009
  • uddhavjoglekar
  • dancingshell
  • rysmithprocore
  • robbiegprocore
  • jadamsss
  • jeremy.bouzigard
  • timdoherty
  • b.bookout
  • jalyng
  • htael
  • dev-account-admin
  • sseanwang
  • bhargavrnd
  • farismmk
  • dannyporrello
  • danny.ou
  • messanjah
  • eyvettesou
  • jgee67
  • cagmz
  • mariah_delaney
  • lukenispel
  • kimhin267
  • juliana.hernandez
  • judy-lu-pc
  • procore-it-support
  • andrewburke-pc
  • jkleintech
  • rachel.arkebauer
  • procore-npm-bot
  • james.dabbs-procore
  • laurenbrandsteinprocore
  • scottbieser-procore
  • zach.mckenzie.procore
  • shayonj_procore
  • heplayskeys
  • mike.south
  • thomasoboyle
  • dischorde
  • derek-carter-procore
  • dlgasser
  • cfprocore
  • evan.waits
  • jeremy-marcus
  • jmejia-fsl
  • ersgonzalo
  • stephan-procore
  • aleclarsenprocore
  • yihai.zweifel
  • jay-rajan
  • jacky-lei
  • peter.jin