Rendering

isServer

Edit this page

isServer is a constant boolean that indicates whether code is running in the server bundle.


Import

import { isServer } from "solid-js/web";

Type

const isServer: boolean;

Behavior

  • isServer is true in the server bundle and false in the browser bundle.
  • Because it is exported as a constant, bundlers can eliminate unreachable branches.

Examples

Basic usage

import { isServer } from "solid-js/web";
if (isServer) {
serverOnlyWork();
}

Report an issue with this page