Rendering & SSR

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 than typeof window checks.

Learn more

Last updated: 9/27/26, 8:11 AMEdit this pageReport an issue with this page