
ctrl+k
Enter a search term above to see results...
Enter a search term above to see results...
The SSR utilities provide constants for detecting whether the code is running on the server or client side.
const isServer
A boolean constant indicating whether the current environment is server-side.
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");}
const isClient
A boolean constant indicating whether the current environment is client-side (browser).
import { isClient } from '@semantic-ui/utils';
if (isClient) { document.addEventListener('DOMContentLoaded', () => { console.log("DOM is fully loaded and parsed"); });}
const isDevelopment
A boolean constant indicating whether the current environment is development.
Development Mode Detection
Returns
true
when 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 |
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';
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 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 |
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;