Skip to content

Commit

Permalink
Improve SSR detection logic (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-rossati committed Jul 26, 2022
1 parent f641b5b commit 4902b7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ssr-polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import csrPlug, {Plug} from '@croct/plug';

export function isSsr(): boolean {
return typeof window === 'undefined';
return typeof window === 'undefined'
|| typeof window.document === 'undefined'
|| typeof window.document.createElement === 'undefined';
}

export const croct: Plug = !isSsr() ? csrPlug : new Proxy(csrPlug, {
Expand Down

0 comments on commit 4902b7c

Please sign in to comment.