Commit 9a159e3
fix: replace typeof window with typeof document for SSR detection
Node.js 25+ ships window as an alias for globalThis (Web Storage API
experiment), which breaks the typeof window === 'undefined' SSR guard:
- isServer evaluates to false on the server
- ThemeScript nonce logic misbehaves server-side
- getTheme() calls localStorage.getItem() on the server
- Results in: TypeError: localStorage.getItem is not a function
Fix: use typeof document === 'undefined' instead. document is a
browser-only API that Node.js does not expose (even in v25+), making
it a reliable SSR guard across all Node.js versions.
Fixes #389
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent a7eeabc commit 9a159e3
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
0 commit comments