@revealui/config
v0.4.2
Published
Type-safe environment configuration with Zod validation and lazy proxy loading
Maintainers
Readme
title: "@revealui/config" description: "Environment configuration management for RevealUI - type-safe environment variables with Zod validation." visibility: public status: verified audience: user
@revealui/config
Environment configuration management for RevealUI - type-safe environment variables with Zod validation.
Features
- Type-safe: Full TypeScript support with Zod validation
- Environment detection: Automatically detects NODE_ENV
- Dotenv loading: Loads
.envfiles with priority - Validation: Validates all environment variables on load
- MCP Configuration: Configuration management for MCP servers
- RevealUI Config: RevealUI-specific configuration
Installation
pnpm add @revealui/configUsage
Load Environment Configuration
import { getConfig } from '@revealui/config'
// Get validated config (cached after first call)
const config = getConfig()
// Access validated config
console.log(config.database.url) // Type-safe access
console.log(config.stripe.secretKey)
console.log(config.storage.blobToken)The package also exports a lazy-proxy default export that validates on first property access:
import config from '@revealui/config'
// Validation runs on first property access, not on import
console.log(config.database.url)RevealUI Shared Configuration
The ./revealui subpath provides shared framework config for apps in the monorepo:
import { getSharedCMSConfig, getSharedWebConfig } from '@revealui/config/revealui'
// In apps/admin revealui.config.ts
export default buildConfig({ ...getSharedCMSConfig(), /* app overrides */ })
// In Vite-based apps
const config = { ...getSharedWebConfig(), /* app overrides */ }MCP Configuration
import { getMcpConfig } from '@revealui/config/mcp'
const mcpConfig = getMcpConfig()
// Returns: { persistenceDriver, electricDatabaseUrl, electricApiKey, metricsMode, pgvectorEnabled }Environment Variables
The config package validates these environment variables:
Required Variables
# Database
POSTGRES_URL=postgresql://user:password@host/database
# RevealUI
REVEALUI_SECRET=your_secret_key_here
REVEALUI_PUBLIC_SERVER_URL=http://localhost:4000Optional Variables
# Stripe
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Vercel
VERCEL_API_KEY=vercel_...
BLOB_READ_WRITE_TOKEN=vercel_blob_...
# Neon
NEON_API_KEY=neon_...Note: prior versions of this list included a
SUPABASE_*block. Those env vars are not validated by@revealui/configand were a stale leak from the customer-facing Supabase MCP adapter (which lives atpackages/mcp/src/servers/supabase.tsand documents its own env vars inpackages/mcp/README.md). If you're configuring the Supabase MCP server for customer use, see the MCP README; this package validates only the runtime env that@revealui/serverand@revealui/adminactually read.
File Loading Priority
Environment variables are loaded in this order (later overrides earlier):
- System environment variables
.env(shared defaults, if present).env.local(local overrides).env.development.local(development mode).env.production.local(production mode)
Validation
The package uses Zod schemas to validate configuration:
import { loadConfig } from '@revealui/config'
try {
const config = loadConfig()
// Config is valid and type-safe
} catch (error) {
// Validation failed - missing or invalid variables
console.error('Configuration error:', error)
}Development
# Build package
pnpm --filter @revealui/config build
# Run tests
pnpm --filter @revealui/config test
# Type check
pnpm --filter @revealui/config typecheck
# Lint
pnpm --filter @revealui/config lintWhen to Use This
- You need type-safe access to environment variables with Zod validation
- You want automatic
.envfile loading with priority-based overrides - You're configuring MCP servers or RevealUI-specific settings
- Not for runtime feature flags - use
@revealui/core/featuresinstead - Not for secrets management - use your platform's secret store and let this package validate what's loaded
Design Principles
- Unified: One config loader validates and types all environment variables across every app and package
- Hermetic: Validation runs at load time - invalid or missing variables fail fast, never leak into runtime
Related Documentation
- Environment Variables Guide - Complete environment setup
- Quick Start - Initial setup instructions
- MCP Guide - MCP server configuration
License
MIT
