From 49cf1f2e23eac61c782bea0dec5777f6c220cfa3 Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Mon, 14 Oct 2024 17:51:46 +0200 Subject: [PATCH] fix window checks for SSR --- components/use-local-storage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/use-local-storage.js b/components/use-local-storage.js index fcf09aa2..732d9ded 100644 --- a/components/use-local-storage.js +++ b/components/use-local-storage.js @@ -70,10 +70,10 @@ export async function listLocalStorages ({ userId, database }) { */ function createMemBackend (userId, namespace) { const joinedNamespace = userId + ':' + namespace.join(':') - let memory = window?.snMemStorage?.[joinedNamespace] + let memory = typeof window !== 'undefined' ? window?.snMemStorage?.[joinedNamespace] : null if (!memory) { memory = {} - if (window) { + if (typeof window !== 'undefined') { if (!window.snMemStorage) window.snMemStorage = {} window.snMemStorage[joinedNamespace] = memory }