🎯 Zero Configuration Setup
Works instantly out of the box. Drop in a config file and start using it immediately with automatic TypeScript support and intelligent defaults.
TypeScript-first configuration loader with automatic environment variable detection, validation, and zero dependencies.

// app.config.ts
export default {
server: {
port: 3000,
host: 'localhost'
},
database: {
url: 'postgresql://localhost:5432/myapp',
pool: 10
}
}// app.ts
import { config } from 'bunfig'
const { server, database } = await config({ name: 'app' })
console.log(`Server starting on ${server.host}:${server.port}`)
// Environment variables automatically override:
// APP_SERVER_PORT=8080 → server.port becomes 8080| Feature | bunfig | c12 | dotenv | node-config | cosmiconfig | rc |
|---|---|---|---|---|---|---|
| TypeScript First | ✅ | ⚠️ | ❌ | ❌ | ⚠️ | ❌ |
| Zero Dependencies | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ |
| Auto Env Vars | ✅ | ✅ | ⚠️ | ⚠️ | ❌ | ⚠️ |
| Built-in Validation | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Multiple Sources | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| Home Directory (~/.config) | ✅ | ✅ | ❌ | ❌ | ⚠️ | ⚠️ |
| Hot Reload | ✅ | ⚠️ | ❌ | ❌ | ❌ | ❌ |
| Error Recovery | ✅ | ❌ | ❌ | ⚠️ | ❌ | ❌ |
| Performance Caching | ✅ | ❌ | ❌ | ⚠️ | ❌ | ❌ |
| Smart Type Conversion | ✅ | ⚠️ | ❌ | ⚠️ | ❌ | ❌ |
| Package.json Support | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ |
| Bun Optimized | ✅ | ⚠️ | ⚠️ | ⚠️ | ⚠️ | ⚠️ |
bunfig doesn't just load configuration - it understands it. With smart naming conventions, automatic type conversion, and intelligent file discovery, it feels like magic:
# Set an environment variable
export APP_DATABASE_POOL_SIZE=20
# bunfig automatically maps it to
config.database.pool.size = 20 // (as a number!)Seamlessly transition from development to production with the same configuration API:
// Development: loads from app.config.ts
const config = await loadConfig({ name: 'app' })
// Production: automatically uses environment variables
// APP_DATABASE_URL, APP_SERVER_PORT, etc.Built for production with comprehensive error handling, validation, and monitoring:
const config = await loadConfig({
name: 'app',
schema: productionSchema,
fallback: safeDefaults,
validate: customValidation
})// server.config.ts
export default {
http: { port: 3000, host: 'localhost' },
cors: { enabled: true, origins: ['http://localhost:3000'] },
rateLimit: { enabled: true, maxRequests: 100 }
}
// Automatically uses environment variables:
// SERVER_HTTP_PORT=8080
// SERVER_CORS_ORIGINS=https://myapp.com,https://api.myapp.comconst dbConfig = await config({
name: 'database',
schema: {
type: 'object',
properties: {
url: { type: 'string', pattern: '^postgresql://' },
pool: { type: 'number', minimum: 1, maximum: 100 }
},
required: ['url']
}
})// config/development.config.ts
export default {
database: { url: 'postgresql://localhost:5432/dev' },
logging: { level: 'debug' }
}
// config/production.config.ts
export default {
database: { url: process.env.DATABASE_URL },
logging: { level: 'error' }
}
// Load environment-specific config
const env = process.env.NODE_ENV || 'development'
const config = await loadConfig({ name: env, cwd: './config' })Install bunfig
bun add bunfigCreate a config file
// app.config.ts
export default {
port: 3000,
host: 'localhost'
}Load and use
import { config } from 'bunfig'
const { port, host } = await config({ name: 'app' })