On This Page
Constants
SSR Utilities
The SSR utilities provide constants for detecting whether the code is running on the server or client side.
Constants
isServer
const isServerA 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 isClientA 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 isDevelopmentA boolean constant indicating whether the current environment is development.
Development Mode Detection
Returns
truewhen any of these conditions are met:
| Environment | Variable | Values |
|---|---|---|
| Cloud Dev | CODESPACE_NAME | any value |
GITPOD_WORKSPACE_ID | any value | |
| Vercel | VERCEL_ENV | "development", "preview" |
| Netlify | CONTEXT | "deploy-preview", "branch-deploy", "dev" |
| Node.js | NODE_ENV | "development", "dev", "local", "test" |
| Vite | import.meta.env.DEV | true |
import.meta.env.MODE | any value except "production" | |
| Nuxt | process.dev | true |
| React Native | __DEV__ | true |
Example
import { isDevelopment } from '@semantic-ui/utils';
if (isDevelopment) { console.log('Debug info enabled');}
// API endpoint selectionconst apiUrl = isDevelopment ? 'http://localhost:3000/api' : 'https://api.production.com';isCI
const isCIA boolean constant indicating whether the current environment is a CI/CD pipeline.
CI Platform Detection
Returns
truewhen any of these conditions are met:
| Detection Method | Variable | Values |
|---|---|---|
| Generic | CI | "true", true |
| GitHub Actions | GITHUB_ACTIONS | any value |
| GitLab CI | GITLAB_CI | any value |
| Jenkins | JENKINS_URL | any value |
| Buildkite | BUILDKITE | any value |
| CircleCI | CIRCLECI | any value |
| Travis CI | TRAVIS | any value |
| AppVeyor | APPVEYOR | any value |
| Drone | DRONE | any value |
| Semaphore | SEMAPHORE | any value |
| TeamCity | TEAMCITY_VERSION | any value |
| Azure DevOps | TF_BUILD | any value |
| Bamboo | BAMBOO_BUILD_KEY | any value |
| AWS CodeBuild | CODEBUILD_BUILD_ID | any value |
Example
import { isCI } from '@semantic-ui/utils';
// Skip interactive prompts in CIif (isCI) { console.log('CI detected - using default settings');} else { console.log('Local environment - prompting for input');}
// Different timeouts for CI vs localconst timeout = isCI ? 30000 : 5000;