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
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 withREACT_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
Variable Precedence
When multiple variables have the same name:- Manual deployment overrides (highest priority)
- Environment configuration variables
- System variables (lowest priority)
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
Accessing in Different Frameworks
Next.js App Router
app/api/info/route.ts
SvelteKit
Remix
Nuxt 3
server/api/info.ts
Related Documentation
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