npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kfg

v1.2.0

Published

Simple system of standardization of configurations for node js and bun.

Readme

K(con)fg - Simple, Type-Safe Configuration Management

npm version Documentation

Kfg is a robust and 100% type-safe configuration management system for Node.js and Bun applications. It provides a structured way to define, validate, and access environment variables and other configuration sources with the power of TypeScript.

  • Fully Typed: Autocomplete and type safety for all your configurations.

  • Flexible Drivers: Load configurations from .env files, JSON, or create your own driver.

  • Built-in Validation: Define rules and formats (email, url, etc.) directly in the schema.

  • Smart Defaults: Define defaults that are applied automatically.

  • Nested Structures: Organize your configurations logically.

  • File-based Configuration: Manage configurations across multiple files with Kfg.

  • Relations: Create one-to-one and one-to-many relations between configurations.


📖 Documentation

Installation

npm install kfg
# or
yarn add kfg
# or
bun add kfg

Quick Example

1. Define your schema (schema.ts):

import { c } from "kfg";

export const AppSchema = {
  server: {
    host: c.string({ default: "0.0.0.0" }),
    port: c.number({ default: 3000 }),
  },
  database: {
    url: c.string({ prop: "DATABASE_URL" }), // Reads from the DATABASE_URL environment variable
  },
};

2. Create and load your instance (config.ts):

import { Kfg } from "kfg";
import { envDriver } from "kfg/drivers";
import { AppSchema } from "./schema";

const config = new Kfg(envDriver, AppSchema);
config.load(); // Loads values from .env and process.env

export default config;

3. Use it anywhere (index.ts):

import config from "./config";

const port = config.get("server.port"); // Inferred as `number`
const dbUrl = config.get("database.url"); // Inferred as `string`

console.log(`Server running on port ${port}`);

// Type Error! TypeScript prevents incorrect assignments.
// config.set("server.port", "not-a-number");

File-based Configuration with Kfg

Kfg allows you to manage configurations across multiple files, which is useful for managing configurations for different users, tenants, or environments.

1. Define your schemas:

import { Kfg, c, cfs, jsonDriver } from "kfg";

const inventory = new Kfg(jsonDriver, {
    items: c.array(c.string()),
});

const user = new Kfg(jsonDriver, {
    name: c.string(),
    inventory_ids: cfs.many(inventory),
});

2. Initialize Kfg:

inventory.init((id) => `resources/inventory/${id}.json`);
user.init((id) => `resources/users/${id}.json`);

3. Use it:

const user1 = user.file("user-1");
user1.set("name", "Alice");

const inv1 = inventory.file("inv-1");
inv1.set("items", ["sword", "shield"]);

user1.set("inventory_ids", [inv1]);

const user1Inventories = await user1.getMany("inventory_ids");

License

MIT