Env Diff

Env Diff is a copy-paste React component that stops prod still pointing at localhost before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/env-diff
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsProd still pointing at localhost

Was this component page useful?

How do I install Env Diff?

pnpm dlx shadcn@latest add @bollard/env-diff

The files land in your project. They're yours to edit.

How do I use Env Diff in React?

env-diff-usage.tsx
import { EnvDiff } from "@/components/ui/env-diff"

return <EnvDiff base={staging} target={production} baseName="staging" targetName="production" />

What input mistakes does Env Diff catch?

  • Keys missing or empty in one environment
  • Production values that point at localhost, a test key or a staging host
  • Secrets reused across both environments
  • A copy of the missing keys, ready to fill

What props does Env Diff accept?

EnvDiff props
PropTypeDefault
base* (required)

Reference environment: dotenv text or a key/value map.

string | Record<string, string>—
target* (required)

Environment being checked against the reference.

string | Record<string, string>—
baseName

Name of the reference environment. Also used to spot its values leaking into the target.

string"staging"
targetName

Name of the environment being checked.

string"production"
production

Treat the target as production: test keys and localhost values are flagged. Defaults to a name containing "prod" or "live".

boolean/\b(prod|production|prd|live)\b/i.test(targetName)
isSecret

Decides which keys are secret. Defaults to names containing SECRET, TOKEN, PASSWORD, KEY, DSN…

(key: string) => boolean—
showSame

Show unchanged keys too. They are hidden by default so the real differences stand out.

booleanfalse
statusLabels

Badge text per status. `{target}` is filled in.

Partial<Record<EnvDiffStatus, string>>—
hints

Explanation per status. `{base}`, `{target}` and `{reason}` are filled in.

Partial<Record<EnvDiffStatus, string>>—
cleanText

Summary when nothing needs attention.

string"{target} has everything {base} has."
problemsText

Summary when something does. `{count}` is filled in.

string"{count} to fix before deploying {target}"
copyMissingLabel

Label of the button that copies the missing keys as a KEY= template. `{count}` is filled in.

string"Copy {count} missing"
copiedLabel

Label shown after copying.

string"Copied"
showSameLabel

Label of the toggle for unchanged keys. `{count}` is filled in.

string"Show {count} unchanged"
hideSameLabel

Label of the same toggle while unchanged keys are shown.

string"Hide unchanged"
notSetText

Shown where a key isn't set.

string"not set"
emptyText

Shown where a value is an empty string.

string"empty"
maskedText

Read by screen readers for a masked value. `{fingerprint}` is filled in.

string"Masked value, fingerprint {fingerprint}. Matching finger…
secretText

Read by screen readers next to a secret key.

string"Secret"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Env Diff accessible?

  • The comparison is a labelled list; masked dots are aria-hidden and secrets have a labelled icon
  • Show-same toggle uses aria-pressed
  • Copy feedback is aria-live="polite"

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Validate required config at deploy time on the server, and keep secrets in a secrets manager rather than in shared diffs.

  • Fingerprints are 4-hex-digit FNV hashes: fine for spotting reuse, but they can help confirm guesses of short, weak secrets, so don't share diffs of weak secrets
  • Which keys are secret is decided by isSecret or name patterns

What expensive mistakes does Env Diff stop?

Prod still pointing at localhost

Also known as

.env · environment variables · config · staging · production · vercel env · secrets · deploy

Field type

What dependencies does Env Diff require?

Env Diff facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameEnv Diff
Registry identifier@bollard/env-diff
Install commandnpx shadcn@latest add @bollard/env-diff
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Env Diff

What form validation mistake does Env Diff catch?

Env Diff prevents prod still pointing at localhost. Compares two environments key by key and flags missing keys, localhost in production and reused secrets, masking secrets so the diff is safe to share. Catches: Keys missing or empty in one environment, Production values that point at localhost, a test key or a staging host, Secrets reused across both environments, A copy of the missing keys, ready to fill. Limitation: validate env-diff schemas on backend.

How do I install env-diff with shadcn?

Run `npx shadcn@latest add @bollard/env-diff`. Sources added: registry/default/env-diff/env-diff.tsx. Package requirements: lucide-react.

What props customize Env Diff?

Env Diff accepts `base`, `target`, `baseName`, `targetName`, `production`. Configures .env, environment variables, config behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of env-diff?

Fingerprints are 4-hex-digit FNV hashes: fine for spotting reuse, but they can help confirm guesses of short, weak secrets, so don't share diffs of weak secrets. Which keys are secret is decided by isSecret or name patterns Server requirement: Validate required config at deploy time on the server, and keep secrets in a secrets manager rather than in shared diffs.

How does Env Diff meet accessibility guidelines?

The comparison is a labelled list; masked dots are aria-hidden and secrets have a labelled icon. Show-same toggle uses aria-pressed. Copy feedback is aria-live="polite". Minimizes errors: missing env variable in prod, staging url in production.

Which components pair with Env Diff?