Skip to main content

Overview

Canvas apps have two ways to access configuration:
  1. Browser runtimewindow.__MIXPEEK__ (injected into every HTML response)
  2. Server functionsctx.env (available in your handler’s context)

Browser runtime variables

Canvas automatically injects a window.__MIXPEEK__ object into every HTML page. This includes system variables and any custom environment variables you configure.

System variables (always available)

Accessing in your app

Use window.__MIXPEEK__.apiBaseUrl (which resolves to /api) instead of hardcoding https://api.mixpeek.com. The Canvas proxy injects your API key and namespace header server-side, keeping credentials out of the browser.

Custom environment variables

Set custom environment variables on your app via the API:
Custom env vars are:
  • Injected into window.__MIXPEEK__ for browser access
  • Available as ctx.env in server functions
  • Stored encrypted and never exposed in build logs

Server function environment

Server functions receive all environment variables through ctx.env:
Server functions also have access to system environment variables like MIXPEEK_API_KEY and MIXPEEK_NAMESPACE_ID — these are injected server-side and never reach the browser.

Environment-specific variables

Since Canvas supports multiple environments (production, staging, preview), you can set different variables per environment by deploying with different configurations.