Skip to main content

Environment Variables

Set environment variables that are available during the build process and at runtime.

Adding environment variables​

  1. Go to your site's Settings tab
  2. Under Environment Variables, click Add Variable
  3. Enter the key and value
  4. Click Save

Usage​

Environment variables are injected during the build process. Access them the same way you normally would in your framework:

Next.js​

// Only variables prefixed with NEXT_PUBLIC_ are available in the browser
const apiUrl = process.env.NEXT_PUBLIC_API_URL

Vite (React, Vue, Svelte)​

// Only variables prefixed with VITE_ are available in the browser
const apiUrl = import.meta.env.VITE_API_URL

Astro​

const apiUrl = import.meta.env.PUBLIC_API_URL
caution

Never store secrets (API keys, passwords) in client-side environment variables. Variables prefixed with NEXT_PUBLIC_, VITE_, etc. are embedded in your built JavaScript and visible to anyone.

Built-in variables​

WebStadia automatically provides these variables during builds:

VariableDescription
WEBSTADIAAlways true - detect if running on WebStadia
NODE_VERSIONNode.js version used for the build