Env Editor

View as Markdown

Names and values such as API keys and URLs, one row each: secrets hidden, a pasted .env file split into rows, mistakes marked.

Production

5 variables · 2 secrets

Paste a .env file into a name to add every line.

When to use

Names and values such as API keys and URLs, one row each: secrets hidden, a pasted .env file split into rows, mistakes marked. Use Secrets instead when the values are credentials no one should read again after saving.

Usage

import { EnvEditor, type EnvVar } from "./ui/uicontext/components/EnvEditor.ts"
export const Settings = <M>(h: Html.H<M>, env: ReadonlyArray<EnvVar>, onChange: (vars: ReadonlyArray<EnvVar>, valid: boolean) => M) =>	EnvEditor(h, { props: { label: "Environment variables", value: env }, onEmit: { RequestedChange: ({ value, valid }) => onChange(value, valid) } })

Examples

Pasting a .env file

Copy the file and paste it into the name field. The dash in ALLOWED-ORIGINS is marked, and Save waits until it's fixed.

# an MCP server's settings
export GITHUB_TOKEN="ghp_exampleOnly000"
SEARCH_INDEX=issues-v2   # the index to query
MAX_RESULTS=25
ALLOWED-ORIGINS=*

Tool settings

0 variables

Paste a .env file into a name to add every line.

API reference

Props

EnvEditor props
NameTypeDefaultDescription
labelrequiredstring—What the variables are for: "Production environment".
valuerequiredEnvVar[]—The variables to start with.
idstring"env"Starts the ids inside it, unique on the page; "env" by default.
localestring—For the counts; the browser's by default.

Events

EnvEditor events
EventPayloadDescription
RequestedChange{ value: EnvVar[]; valid: boolean }The set changed: the named variables, in order, and whether every row is fine to save.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/env-editor

Source