From 79273d263b9f65dbe4faf369fa936e8d746d81d2 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 26 Jun 2023 02:07:03 -0400 Subject: [PATCH] fix: switch to using globalThis, and check if we have localStorage (if not, might be node) --- src/portal.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/portal.ts b/src/portal.ts index 7ecd198..ca8434d 100644 --- a/src/portal.ts +++ b/src/portal.ts @@ -75,7 +75,11 @@ export function initPortal(portal: Portal): Client { } export function getPortalSessions() { - let portalSessionsData = window.localStorage.getItem("portals"); + if (typeof globalThis.localStorage === "undefined") { + return undefined; + } + + let portalSessionsData = globalThis.localStorage.getItem("portals"); let portalSessions: PortalSessionsStore = {}; if (portalSessions) { portalSessions = JSON.parse(