fleeting-garden/src/utils/browser-storage.ts
Andras Schmelczer 2347ecd201
Some checks failed
Deploy to Pages / build (pull_request) Failing after 3m15s
.
2026-05-13 22:13:15 +01:00

17 lines
467 B
TypeScript

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