isServer
Build-time constant that is true in server output and false in browser output.
Import
import { isServer } from "@solidjs/web";Type signature
const isServer: boolean;Examples
import { isServer } from "@solidjs/web";
if (!isServer) { // Browser-only: tree-shaken out of the SSR bundle. window.addEventListener("resize", onResize);}if (!isServer) { window.addEventListener("resize", onResize);}Caveats
- It is a build-time constant. Code behind
if (!isServer)is removed from the server bundle, so use it rather thantypeof windowchecks.