diff --git a/src/lib/browser.ts b/src/lib/browser.ts index 730d0e2aa..b8a3fa4d9 100644 --- a/src/lib/browser.ts +++ b/src/lib/browser.ts @@ -1,4 +1,8 @@ export function getUrlParams() { + if (typeof window === 'undefined') { + return {}; + } + const params = new URLSearchParams(window.location.search); const paramsObj: Record = {}; for (const [key, value] of params.entries()) { @@ -9,6 +13,10 @@ export function getUrlParams() { } export function deleteUrlParam(key: string) { + if (typeof window === 'undefined') { + return; + } + const url = new URL(window.location.href); if (!url.searchParams.has(key)) { return; @@ -19,6 +27,10 @@ export function deleteUrlParam(key: string) { } export function setUrlParams(params: Record) { + if (typeof window === 'undefined') { + return; + } + const url = new URL(window.location.href); for (const [key, value] of Object.entries(params)) {