Some checks failed
Deploy to Pages / build (pull_request) Failing after 3m15s
17 lines
467 B
TypeScript
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.
|
|
}
|
|
};
|