fleeting-garden/src/utils/browser-storage.ts

18 lines
414 B
TypeScript

export const readBrowserStorage = (key: string): string | null => {
try {
return localStorage.getItem(key);
} catch {
return null;
}
};
export const writeBrowserStorage = (key: string, value: string): void => {
try {
localStorage.setItem(key, value);
} catch (error) {
console.warn(
'Storage can be unavailable in private browsing or embedded contexts.',
error
);
}
};