Skip to content

Commit

Permalink
fix: isBrowser to include typeof window !== 'undefined' check
Browse files Browse the repository at this point in the history
There are several checks in GoTrueClient.ts that check window?.[prop] after checking isBrowser() which throws an error in node environments that have "document" defined but not "window". So this is the most minimal check to  be sure they don't throw by ensuring "window" is defined.
  • Loading branch information
salmoro committed Dec 12, 2024
1 parent b045965 commit 92ddfb9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function uuid() {
})
}

export const isBrowser = () => typeof document !== 'undefined'
export const isBrowser = () =>
typeof window !== 'undefined' && typeof document !== 'undefined'

const localStorageWriteTests = {
tested: false,
Expand Down

0 comments on commit 92ddfb9

Please sign in to comment.