# bunfig

> A smart & fully-typed configuration loader for Bun.

Latest version **0.15.19** (published 2026-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install bunfig
pnpm add bunfig
yarn add bunfig
bun add bunfig
```

Provides the command `bunfig`.

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.15.19 |
| Published | 2026-08-19 |
| First published | 2024-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 705.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 16 |
| Author | Chris Breuer <chris@stacksjs.org> |
| Maintainers | chrisbreuer |
| Keywords | config, loader, bun, bunfig |

## Links

- npm: https://www.npmjs.com/package/bunfig
- Repository: https://github.com/stacksjs/bunfig
- Homepage: https://github.com/stacksjs/bunfig#readme
- Issues: https://github.com/stacksjs/bunfig/issues
- npm.io page: https://npm.io/package/bunfig

## Dependencies (1)

- [@stacksjs/clarity](https://npm.io/package/@stacksjs/clarity.md) ^0.3.24

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.15.19 (latest) — 2026-08-19
- 0.15.18 — 2026-08-19
- 0.15.17 — 2026-07-31
- 0.15.16 — 2026-07-31
- 0.15.15 — 2026-07-16
- 0.15.14 — 2026-06-10
- 0.15.13 — 2026-05-08
- 0.15.12 — 2026-05-08
- 0.15.11 — 2026-05-02
- 0.15.10 — 2026-05-02
- 0.15.9 — 2026-04-29
- 0.15.8 — 2026-04-27
- 0.15.7 — 2026-04-27
- 0.15.6 — 2025-10-30
- 0.15.5 — 2025-10-29
- … 24 more at https://npm.io/package/bunfig/versions

## README

# bunfig

A smart and fully-typed configuration loader for Bun.

## Installation

```bash
bun add bunfig
```

```bash
npm install bunfig
```

## Usage

```typescript
import type { Config } from 'bunfig'
import { loadConfig } from 'bunfig'

interface AppConfig {
  port: number
  host: string
  debug: boolean
}

const config = await loadConfig<AppConfig>({
  name: 'my-app',
  defaultConfig: {
    port: 3000,
    host: 'localhost',
    debug: false,
  },
})

console.log(config.port) // 3000
```

Create a `my-app.config.ts` file in your project root:

```typescript
export default {
  port: 8080,
  host: '0.0.0.0',
  debug: true,
}
```

## Features

- **Zero Configuration Setup** - Works out of the box with intelligent defaults
- **Environment Variable Detection** - Automatically detects and merges env vars with smart naming conventions
- **TypeScript First** - Full TypeScript support with type inference and autocompletion
- **Smart File Discovery** - Finds config files in project root, home directory, or package.json
- **JSON Schema Validation** - Validate configurations with detailed error reporting
- **Zero Dependencies** - Lightweight with intelligent caching
- **XDG Standards Compliant** - Global configs via `~/.config/$name/` following XDG standards
- **Hot Reload Ready** - Watch for config changes and reload automatically
- **Browser Support** - Works in both server and browser environments
- **CLI** - Built-in CLI for managing configurations

## License

MIT

---
_Source: https://npm.io/package/bunfig · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
