Skip to content

Environment Variables

Velocity uses environment variables for configuration that varies between environments.

Create your environment file from the example:

Terminal window
cp .env.example .env
Terminal window
# Your production domain (no trailing slash)
SITE_URL=https://yoursite.com
Terminal window
# Google Analytics
PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
# Google Tag Manager
PUBLIC_GTM_ID=GTM-XXXXXXX
Terminal window
# Custom form endpoint
CONTACT_FORM_ENDPOINT=https://api.yoursite.com/contact
Terminal window
# Search engine verification codes
GOOGLE_SITE_VERIFICATION=your-google-code
BING_SITE_VERIFICATION=your-bing-code
Terminal window
PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX # ✅ Safe - just a tracking ID
PUBLIC_API_URL=https://api.example.com # ✅ Safe - public endpoint
Terminal window
API_SECRET_KEY=sk_live_xxxxx # ✅ Safe - server only
DATABASE_URL=postgres://... # ✅ Safe - server only
PUBLIC_API_KEY=sk_xxxxx # ❌ DANGER - exposed to browser!
---
// Server-side (both public and private)
const siteUrl = import.meta.env.SITE_URL;
const apiKey = import.meta.env.API_SECRET_KEY;
---
// Only PUBLIC_ prefixed variables work here
const gaId = import.meta.env.PUBLIC_GA_MEASUREMENT_ID;

For different environments, create:

  • .env — Local development (not committed)
  • .env.production — Production overrides
  • .env.example — Template for team members (committed)

Set variables in Project Settings → Environment Variables.

Set variables in Site Settings → Build & Deploy → Environment.

Set variables in Settings → Environment Variables.