Skip to main content

Overview

Stormkit automatically injects several environment variables into your deployment environment. These variables are available during:
  • Build time - When your application is being built
  • Runtime - When serverless functions execute
  • Status checks - When post-deployment tests run
Use these variables to customize behavior based on the deployment context.

Available Variables

Usage Examples

Detecting Stormkit Environment

Check if your code is running on Stormkit:

Environment-Specific Configuration

Use different settings per environment:
config.js

Preview URL in API Calls

Construct URLs dynamically based on deployment:

Git Information in Application

Display deployment information to users:

Environment-Based Feature Flags

Build-Time Usage

Access variables during build in your build scripts:

Next.js

next.config.js

Vite

vite.config.js

Create React App

Prefix with REACT_APP_ to expose to browser:
.env.production

Runtime Usage

Access variables in serverless functions:

API Function Example

api/info.js

Server-Side Rendering

server/index.ts

Status Check Usage

Use deployment URL in status checks:
scripts/status-check.js

TypeScript Types

Define types for system variables:
types/env.d.ts
Use with type safety:

Variable Precedence

When multiple variables have the same name:
  1. Manual deployment overrides (highest priority)
  2. Environment configuration variables
  3. System variables (lowest priority)
System variables cannot be overridden by user-defined variables.

Security Considerations

Never Expose Secrets in Client

System variables are safe to use client-side, but don’t expose secrets:

Server-Side Only Variables

Keep sensitive data server-side:
api/secure.js

Best Practices

Use Environment Detection

Instead of hardcoding environment checks:

Version Display

Show version info to users:

Debug Logging

Enable verbose logging in non-production:

Analytics Environment Tagging

Testing Locally

Simulate Stormkit environment locally:
.env.local
Load with dotenv:

Accessing in Different Frameworks

Next.js App Router

app/api/info/route.ts

SvelteKit

Remix

Nuxt 3

server/api/info.ts

Configuration

Configure custom environment variables

Outbound Webhooks

Use system variables in webhooks

Status Checks

Access variables in status checks

How We Deploy

Understand deployment process