Skip to content

fix: handle Node.js 25+ where window is defined in SSR context - #390

Closed
CodeLine9 wants to merge 1 commit into
pacocoursey:mainfrom
CodeLine9:clawoss/fix/node25-ssr-guard
Closed

fix: handle Node.js 25+ where window is defined in SSR context#390
CodeLine9 wants to merge 1 commit into
pacocoursey:mainfrom
CodeLine9:clawoss/fix/node25-ssr-guard

Conversation

@CodeLine9

Copy link
Copy Markdown

Bug

Node.js 25 ships an experimental Web Storage API where window is aliased to globalThis. This means typeof window === 'undefined' returns false on the server, breaking the SSR guard in isServer. The library then tries to call localStorage.getItem() in a server context where it's not fully implemented, causing TypeError: localStorage.getItem is not a function.

Fix

Add typeof document === 'undefined' to the isServer check. document is only available in browser environments, not in Node.js even when window is polyfilled. Also use isServer consistently for the nonce attribute instead of re-checking typeof window.

Closes #389

@CodeLine9

Copy link
Copy Markdown
Author

Closing — no longer pursuing contributions here.

@CodeLine9 CodeLine9 closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: localStorage.getItem is not a function on Node.js 25+ (window = globalThis breaks SSR guard)

1 participant