SSR Utilities API reference for server-side rendering utility functions server API Reference
Categories

SSR Utilities

The SSR utilities provide constants for detecting whether the code is running on the server or client side.

Constants

isServer

const isServer

A boolean constant indicating whether the current environment is server-side.

Example

import { isServer } from '@semantic-ui/utils';
if (isServer) {
console.log("This code is running on the server");
} else {
console.log("This code is running in the browser");
}

isClient

const isClient

A boolean constant indicating whether the current environment is client-side (browser).

Example

import { isClient } from '@semantic-ui/utils';
if (isClient) {
document.addEventListener('DOMContentLoaded', () => {
console.log("DOM is fully loaded and parsed");
});
}

isDevelopment

const isDevelopment

A boolean constant indicating whether the current environment is development.

Development Mode Detection

Returns true when any of these conditions are met:

EnvironmentVariableValues
Cloud DevCODESPACE_NAMEany value
GITPOD_WORKSPACE_IDany value
VercelVERCEL_ENV"development", "preview"
NetlifyCONTEXT"deploy-preview", "branch-deploy", "dev"
Node.jsNODE_ENV"development", "dev", "local", "test"
Viteimport.meta.env.DEVtrue
import.meta.env.MODEany value except "production"
Nuxtprocess.devtrue
React Native__DEV__true

Example

import { isDevelopment } from '@semantic-ui/utils';
if (isDevelopment) {
console.log('Debug info enabled');
}
// API endpoint selection
const apiUrl = isDevelopment
? 'http://localhost:3000/api'
: 'https://api.production.com';

isCI

const isCI

A boolean constant indicating whether the current environment is a CI/CD pipeline.

CI Platform Detection

Returns true when any of these conditions are met:

Detection MethodVariableValues
GenericCI"true", true
GitHub ActionsGITHUB_ACTIONSany value
GitLab CIGITLAB_CIany value
JenkinsJENKINS_URLany value
BuildkiteBUILDKITEany value
CircleCICIRCLECIany value
Travis CITRAVISany value
AppVeyorAPPVEYORany value
DroneDRONEany value
SemaphoreSEMAPHOREany value
TeamCityTEAMCITY_VERSIONany value
Azure DevOpsTF_BUILDany value
BambooBAMBOO_BUILD_KEYany value
AWS CodeBuildCODEBUILD_BUILD_IDany value

Example

import { isCI } from '@semantic-ui/utils';
// Skip interactive prompts in CI
if (isCI) {
console.log('CI detected - using default settings');
} else {
console.log('Local environment - prompting for input');
}
// Different timeouts for CI vs local
const timeout = isCI ? 30000 : 5000;
Previous
Dates
Next
Equality