File size: 534 Bytes
6f91ce5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /**
* Safe localStorage helpers that handle cases where localStorage is not available
* or access is restricted by the browser.
*/
export function getLocalStorageItem(key: string): string | null {
try {
return localStorage.getItem(key)
} catch (error) {
console.warn('Failed to access localStorage:', error)
return null
}
}
export function setLocalStorageItem(key: string, value: string): void {
try {
localStorage.setItem(key, value)
} catch (error) {
console.warn('Failed to set localStorage item:', error)
}
}
|