Overview
Type-safe config. Secure secrets. One import.
Confkit is a tiny, framework‑agnostic runtime for type‑safe configuration and secrets in TypeScript/JavaScript apps. It gives you a single source of truth for configuration, strong types at compile time, validation at runtime, and safe exposure of public values to the client.
Why Confkit?
Most teams re‑invent config handling several times: a schema here, some env parsing there, ad‑hoc redaction, hand‑rolled client env injection… Confkit wraps these concerns into a focused, minimal toolkit that works on Node, serverless, edge, Next.js, Vite and Expo.
One import. Clear layering. First‑class DX.
Install, define your schema, ship.
What You Get
- End‑to‑end types from a single schema
- Multiple sources with explicit layering (env, files, cloud secret stores)
- Runtime validation and deep redaction of secrets
- Explicit client exposure for public values
- CLI + framework plugins for fast feedback (Next, Vite, Expo)
How It Works
Define a schema and layer your sources; Confkit validates and returns a typed object at runtime.
import { defineConfig, s, source } from 'confkit';
export const config = defineConfig({
sources: [
source().env(), // process.env + .env* (in dev)
source().file('config.yaml'), // json/yaml/toml by extension
],
schema: {
NODE_ENV: s.enum(['development','test','production']).default('development'),
PORT: s.port().default(3000),
DATABASE_URL: s.url(),
PUBLIC_APP_NAME: s.string().client().default('confkit'),
STRIPE_SECRET: s.secret(s.string()),
},
});
import { config } from './conf/config';
const env = await config.ready();
console.log('Listening on', env.PORT);
Packages
confkit
: Core runtime, CLI, loader, utilities@confkit/next
: Next.js helpers and dev overlay integration@confkit/vite
: Vite plugin to inject client env and live‑validate@confkit/aws
,@confkit/gcp
,@confkit/azure
,@confkit/doppler
,@confkit/1password
: cloud providers returning Confkit sources
Start Here
New to Confkit? Jump to the Quick Start, then read Schema and Sources & Layering.