New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

coffi

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffi

đź“„ A fast, lightweight, easy-to-use, configuration files loader for Bun

latest
npmnpm
Version
0.1.37
Version published
Maintainers
1
Created
Source

coffi

npm version npm downloads

⚡️ A fast, lightweight, easy-to-use, configuration files loader 📄

Installation

npm install coffi

Usage

Basic Usage

import { loadConfig } from "coffi";

// Loads config from the first matching file extension (see priority list below)
const { config, filepath } = await loadConfig("app.config");

// Or specify custom extensions to search for (in priority order)
const { config } = await loadConfig("tsconfig", [".json"]);

File Priority

The loader checks files in this order:

  • .ts files
  • .mts files
  • .cts files
  • .js files
  • .mjs files
  • .cjs files
  • .json files

You can customize this order using the extensions option.

Options

import { loadConfig } from "coffi";
import path from "node:path";

const { config } = await loadConfig({
  name: "database.config",
  extensions: [".js", ".json", ".ts"],
  cwd: path.join(__dirname, "config"),
  maxDepth: 1, // (set to 1 to search only in current directory)
  preferredPath: "path/to/config.js", // Skip search and load from this path
  packageJsonProperty: "myConfig", // Load configuration from package.json
});

The preferredPath option allows you to specify an exact file path to load, bypassing the normal file search process. When provided, coffi will directly load the configuration from this path.

The packageJsonProperty option allows you to load configuration directly from a property in your project's package.json file. When specified, coffi will look for a property with this name in the nearest package.json file, and if found, will use its value as the configuration. This takes precedence over all other configuration sources, making it convenient for projects where you prefer to keep configuration in package.json.

Keywords

config

FAQs

Package last updated on 04 Oct 2025

Related posts