diff --git a/components/use-local-storage.js b/components/use-local-storage.js index 732d9ded..c0683bda 100644 --- a/components/use-local-storage.js +++ b/components/use-local-storage.js @@ -70,13 +70,13 @@ export async function listLocalStorages ({ userId, database }) { */ function createMemBackend (userId, namespace) { const joinedNamespace = userId + ':' + namespace.join(':') - let memory = typeof window !== 'undefined' ? window?.snMemStorage?.[joinedNamespace] : null - if (!memory) { + let memory + if (SSR) { memory = {} - if (typeof window !== 'undefined') { - if (!window.snMemStorage) window.snMemStorage = {} - window.snMemStorage[joinedNamespace] = memory - } + } else { + if (!window.snMemStorage) window.snMemStorage = {} + memory = window.snMemStorage[joinedNamespace] + if (!memory) window.snMemStorage[joinedNamespace] = memory = {} } return { set: (key, value) => { memory[key] = value }, diff --git a/wallets/webln/client.js b/wallets/webln/client.js index c855cccc..f47e494c 100644 --- a/wallets/webln/client.js +++ b/wallets/webln/client.js @@ -1,6 +1,6 @@ import { useEffect } from 'react' +import { SSR } from '@/lib/constants' export * from 'wallets/webln' - export const sendPayment = async (bolt11) => { if (typeof window.webln === 'undefined') { throw new Error('WebLN provider not found') @@ -22,7 +22,7 @@ export const sendPayment = async (bolt11) => { } export function isAvailable () { - return typeof window !== 'undefined' && window?.weblnEnabled + return !SSR && window?.weblnEnabled } export function WebLnProvider ({ children }) {