UI

Environment variables

Environment variables and secrets manager with masked values, write-only sensitive rows, scope toggle matrix, .env paste import, fingerprint comparison, and a redeploy banner.

import { EnvVariables } from '@uthereal/ui/env-variables'

Env variables playground

Environment variables

northwind-storefront10 keys across 3 environments

  • DATABASE_URLUpdated Aug 12 by Emma Collins
    Hidden value
  • DATABASE_URLUpdated Aug 12 by Emma Collins
    Sensitive value, write-onlySensitive
  • FEATURE_NEW_CHECKOUTUpdated Sep 21 by Emma Collins
    Hidden value
  • FEATURE_NEW_CHECKOUTUpdated Sep 21 by Emma Collins
    Hidden value
  • LOG_LEVELUpdated Apr 8 by Sofia Ramirez
    Hidden value
  • LOG_LEVELUpdated Apr 8 by Sofia Ramirez
    Hidden value
  • NEXT_PUBLIC_SITE_URLUpdated Jun 3 by Marcus Johnson
    Hidden value
  • NEXT_PUBLIC_SITE_URLUpdated Jun 3 by Marcus Johnson
    Hidden value
  • NEXT_PUBLIC_SITE_URLUpdated Jun 3 by Marcus Johnson
    Hidden value
  • REDIS_URLUpdated Sep 18 by Sofia Ramirez
    Hidden value
  • REDIS_URLUpdated Sep 18 by Sofia Ramirez
    Sensitive value, write-onlySensitive
  • RESEND_API_KEYUpdated Jul 19 by Jasmine Brooks
    Hidden value
  • SEARCH_ADMIN_KEYUpdated Jul 30 by Jasmine Brooks
    Sensitive value, write-onlySensitive
  • SENTRY_DSNUpdated May 27 by Marcus Johnson
    Hidden value
  • STRIPE_SECRET_KEYUpdated Sep 2 by Ava Mitchell
    Hidden value
  • STRIPE_SECRET_KEYUpdated Sep 2 by Ava Mitchell
    Sensitive value, write-onlySensitive
  • STRIPE_WEBHOOK_SECRETUpdated Sep 2 by Ava Mitchell
    Sensitive value, write-onlySensitive

Loading interactive preview…

Overview

EnvVariables manages project configuration and secrets across Development, Preview, and Production. Each row pairs one value with the environments it covers, so a single key can hold different values per environment without overlap. Values remain masked and omitted from the DOM until revealed, and rows flagged as sensitive are write-only.

The block includes an inline row editor, an Add variable panel with single-row and Paste .env import modes, a Compare view that diffs two environments by deterministic fingerprint with one-click copy-across actions, and a sliding Redeploy banner that tracks every modified environment.

Use EnvVariables for hosting, deployment, and backend platform settings screens. For managing bring-your-own AI provider credentials, use Keys. For fixed settings that do not vary by environment, use a standard form.

Usage

'use client'
import {
  EnvVariables,
  type EnvName,
  type EnvVariable,
} from '@uthereal/ui/env-variables'

export function ProjectEnvironment({
  project,
  variables,
  onSave,
  onTriggerDeploy,
}: {
  project: string
  variables: EnvVariable[]
  onSave: (rows: EnvVariable[]) => void
  onTriggerDeploy: (environments: EnvName[]) => Promise<void>
}) {
  return (
    <EnvVariables
      project={project}
      variables={variables}
      sampleDotenv=""
      onChange={onSave}
      onRedeploy={onTriggerDeploy}
    />
  )
}

Omit variables and onRedeploy to render the interactive sample project (northwind-storefront) with a locally simulated redeploy lifecycle.

Examples

Empty onboarding state

Pass an empty defaultVariables array and sampleDotenv="" for a new project awaiting its first variable or pasted .env file.

New service environment

northwind-edge-proxy0 keys across 3 environments

No variables yet

Add one, or paste a .env file to import many at once.

Sensitive values and masking

Search matches key names only and never inspects stored values. Row values follow three visibility rules:

Row stateRendered value in DOMReveal & copyInline editor behavior
Hidden (default)Bullets (aria-hidden) + "Hidden value"Reveal togglePre-fills current value; requires non-empty value on save
RevealedPlaintext monospace valueCopy + HideOpening editor hides value again automatically
sensitive: trueBullets (aria-hidden) + "Sensitive value"DisabledStarts empty ("Enter a new value to replace it"); flag cannot be unset

Once a row is saved with sensitive: true, the flag stays locked to prevent accidental disclosure. To make a key readable again, remove the row and add it back.

.env paste importer

Opening Import .env (or pasting a multiline KEY=value block directly into the Key field in single mode) parses the text live against existing rows and target environments. The parser ignores blank lines and # comments, strips export prefixes, unquotes single- and double-quoted strings, and strips trailing inline # comments on unquoted values.

Line statusConditionImport outcome
newValid key not yet set in any chosen environmentImported as a new row
replaceValid key already set in one or more chosen environmentsImported; clears overlapping scopes from existing rows
duplicateSame key appears again on a later valid lineSkipped (last definition wins)
invalidMissing =, empty key, starts with a digit, or bad charsSkipped with inline reason

Compare view and fingerprints

Switching to Compare diffs any two environments (Development, Preview, Production) without exposing plaintext values. Each set variable displays a deterministic 6-character FNV-1a hex fingerprint (•••• a1b2c3) plus a lock indicator when marked sensitive.

Diff statusMeaningAction
missing-targetSet in the base environment, unset in the compared oneCopy to <target> extends the source row
missing-baseSet in the compared environment, unset in the base oneCopy to <base> extends the source row
differentBoth environments define the key with differing fingerprintsHighlighted in accent ink
sameBoth environments matchHidden by default; toggle Show matching to view

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
titlestringDefault: "Environment variables"Heading text and accessible section name.
projectstringDefault: "northwind-storefront"Project slug shown in monospace beneath the heading.
defaultVariablesEnvVariable[]Default: [{"id":"db-prod","key":"DATABASE_URL","value":"postgresql://storefront:Qm7vR2xKp9LwT4nZ@db-prod.northwind.internal:5432/storefront?sslmode=require","environments":["production"],"sensitive":true,"updated":"Aug 12","updatedBy":"Emma Collins"},{"id":"db-dev","key":"DATABASE_URL","value":"postgresql://storefront:preview@db-staging.northwind.internal:5432/storefront_preview","environments":["development","preview"],"sensitive":false,"updated":"Aug 12","updatedBy":"Emma Collins"},{"id":"site-prod","key":"NEXT_PUBLIC_SITE_URL","value":"https://shop.northwind.example","environments":["production"],"sensitive":false,"updated":"Jun 3","updatedBy":"Marcus Johnson"},{"id":"site-preview","key":"NEXT_PUBLIC_SITE_URL","value":"https://preview.northwind.example","environments":["preview"],"sensitive":false,"updated":"Jun 3","updatedBy":"Marcus Johnson"},{"id":"site-dev","key":"NEXT_PUBLIC_SITE_URL","value":"http://localhost:3000","environments":["development"],"sensitive":false,"updated":"Jun 3","updatedBy":"Marcus Johnson"},{"id":"stripe-live","key":"STRIPE_SECRET_KEY","value":"sk_live_51Nw8QeHv2kR9tXa7LmPq4ZsY0bUcJ3dF","environments":["production"],"sensitive":true,"updated":"Sep 2","updatedBy":"Ava Mitchell"},{"id":"stripe-test","key":"STRIPE_SECRET_KEY","value":"sk_test_51Nw8QeHv2kR9tXa7Tg6Wn1KcE5pLr8yV","environments":["development","preview"],"sensitive":false,"updated":"Sep 2","updatedBy":"Ava Mitchell"},{"id":"stripe-hook","key":"STRIPE_WEBHOOK_SECRET","value":"whsec_9f3KqL2vX8mN4pR7tY1wZ6cB5dH0jG","environments":["production"],"sensitive":true,"updated":"Sep 2","updatedBy":"Ava Mitchell"},{"id":"resend","key":"RESEND_API_KEY","value":"re_Hk4q9TzLm_8VbWcN2xPr5sJd7FgY3eA","environments":["development","preview","production"],"sensitive":false,"updated":"Jul 19","updatedBy":"Jasmine Brooks"},{"id":"sentry","key":"SENTRY_DSN","value":"https://4b7e21c9d0a34f86@errors.northwind.example/2","environments":["preview","production"],"sensitive":false,"updated":"May 27","updatedBy":"Marcus Johnson"},{"id":"redis-prod","key":"REDIS_URL","value":"rediss://default:Xt8pL3qW7nZ2@cache-prod.northwind.internal:6380","environments":["production"],"sensitive":true,"updated":"Sep 18","updatedBy":"Sofia Ramirez"},{"id":"redis-preview","key":"REDIS_URL","value":"redis://cache-staging.northwind.internal:6379","environments":["preview"],"sensitive":false,"updated":"Sep 18","updatedBy":"Sofia Ramirez"},{"id":"checkout-flag","key":"FEATURE_NEW_CHECKOUT","value":"true","environments":["development","preview"],"sensitive":false,"updated":"Sep 21","updatedBy":"Emma Collins"},{"id":"checkout-flag-prod","key":"FEATURE_NEW_CHECKOUT","value":"false","environments":["production"],"sensitive":false,"updated":"Sep 21","updatedBy":"Emma Collins"},{"id":"log-dev","key":"LOG_LEVEL","value":"debug","environments":["development"],"sensitive":false,"updated":"Apr 8","updatedBy":"Sofia Ramirez"},{"id":"log","key":"LOG_LEVEL","value":"info","environments":["preview","production"],"sensitive":false,"updated":"Apr 8","updatedBy":"Sofia Ramirez"},{"id":"search-admin","key":"SEARCH_ADMIN_KEY","value":"a1c9f4e27b8d6035e2f7a9b41c8d3e60","environments":["production"],"sensitive":true,"updated":"Jul 30","updatedBy":"Jasmine Brooks"}]Initial environment variable rows when uncontrolled. A key may appear on multiple rows with disjoint environments; rows are sorted by key. Edits do not reset a mounted instance.
sampleDotenvstringDefault: "# Copied from .env.local\nNEXT_PUBLIC_POSTHOG_KEY=phc_Rk2mT8vLq4xW9nZcB7pD1sF6hJ3yG5aE\nSEARCH_ADMIN_KEY=b7e2a9c41d06f8e3a5c2b9d7e14f6a08\nexport SHIPPING_API_TOKEN=\"shippo_test_4e9c2b7a1f8d3e60c5b2\"\nLOG_LEVEL=warn\n2FA_SECRET=JBSWY3DPEHPK3PXP\nLOG_LEVEL=error"Initial text shown in the Paste .env textarea. Pass an empty string for a blank paste area.
redeployActionstring—Registered host action sent when the user clicks Redeploy or Try again in the redeploy banner.
recipestudio | softDefault: "studio"Visual treatment. Both recipes preserve interaction behavior.
themeEnvVariablesThemeDefault: {}Color mode, accent, and typed semantic token overrides.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. System reduced-motion preferences take precedence.
motionOptionsEnvVariablesMotionOptionsDefault: {}Panel expansion and crossfade timing overrides in milliseconds.
dirltr | rtl—Reading direction; inherited from the page when omitted.

EnvVariable accepts { id, key, value, environments, sensitive?, updated?, updatedBy? }, where environments is a non-empty array of unique 'development' | 'preview' | 'production' values.

React integration

PropPurpose
variablesControlled variable rows in any order (sorted by key). Omit for uncontrolled state seeded by defaultVariables.
onChange(variables)Called with the updated sorted row array after every add, import, edit, removal, scope toggle, or copy between environments.
onRedeploy(environments)Called with modified EnvName[] when Redeploy is activated. Return a promise to hold the running state; reject to show retry state.
onAction(action)Called when redeployAction is configured and the user activates Redeploy or Try again.
presetApplication defaults overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme.
ref, className, styleApplied to the root <section> element.
Native attributesid, aria-*, data-*, and remaining <section> props forwarded to the root element.

Keyboard & accessibility

KeyAction
TabMoves through header actions, search, view switch, and each row’s reveal, copy, scope toggle, and edit controls.
Enter / SpaceToggles reveal, flips an environment scope, opens the inline editor, or activates a button.
ArrowLeft / ArrowRightMoves and selects options inside the view switcher, add-mode switcher, and compare environment pickers (RTL-aware).
EscapeCloses the inline editor or add panel and restores focus to the button that opened it.
Enter (in form)Saves the edited value, adds a single variable, or imports parsed .env lines.

Every reveal button and environment scope toggle carries aria-pressed and an explicit key-scoped accessible name (for example, "Production for DATABASE_URL"). Scope conflict warnings render as inline role="alert" notes beneath the row, and a pre-mounted polite role="status" live region announces every mutation, import, removal, and redeploy outcome.

Container queries adapt the layout to its available inline width: at 760px and wider, rows render as a 6-column matrix with per-environment counts; below 760px, each row stacks into a card with a responsive 3-column environment pill grid; below 560px, header actions, search, form buttons, and redeploy actions expand to full width and the .env preview omits the masked value column. On coarse touch pointers, icon buttons and scope toggles grow to 44px targets.

Motion & theming

The redeploy banner, add panel, inline editor, row additions/removals, and conflict alerts expand and collapse on the bounce-free smooth spring (400ms) and exit on the exit curve (180ms). Environment scope toggles fill on the snappy spring (260ms) and draw their checkmark with pathLength. View switches and redeploy state updates spring the container height smoothly without snapping, and saved or imported rows pulse briefly with --ui-accent-subtle.

Under prefers-reduced-motion: reduce, travel, scale, and row highlight loops are disabled and swaps fall back to 120ms opacity crossfades. Setting motion="none" makes every transition immediate (0ms).

theme accepts mode, accent, and typed tokens across these groups:

Token groupCSS custom properties
core--ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-font, --ui-font-size, --ui-font-weight
extended--ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-success, --ui-warning, --ui-info
shape--ui-radius-sm, --ui-popup-radius, --ui-surface-radius
accentTones--ui-accent-strong, --ui-accent-subtle
selectionControl--ui-control-on, --ui-control-glyph, --ui-track, --ui-control-track-hover, --ui-control-thumb, --ui-control-thumb-on
type--ui-font-mono, --ui-font-display
elevation--ui-shadow-resting, --ui-shadow-raised

An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, EnvVariables is a leaf. Supply non-secret placeholder values in defaultVariables and wire redeployAction to a registered host action. See Building with agents.

{
  "type": "EnvVariables",
  "props": {
    "title": "Environment variables",
    "project": "northwind-storefront",
    "redeployAction": "redeploy_project"
  },
  "children": []
}

On this page