Skip to content

morselCome for the lean. Stay for the watch.

The only zero-dep config loader that does discovery, hierarchical merge, live-reload, and plugins.

morsel logo

Interactive Playground

Edit the base or local configuration files to see hierarchical merging and live events in real-time.

morsel
Live
~/config/your-app/your-app.jsonBase Config
./your-app.jsonLocal Config
Events0 events
Your Merged Config

Installation

bash
pnpm add @oclio/morsel
bash
npm install @oclio/morsel
bash
yarn add @oclio/morsel

One-shot load

ts
import { defineConfig, loadConfig } from '@oclio/morsel';

const myApp = defineConfig({
  name: 'myapp',
  defaults: { port: 3000, host: 'localhost' },
});

const { config } = await loadConfig(myApp);
console.log(config.port); // 3000, or overridden by ./myapp.config.json

Live-reload with key-level events

ts
import { defineConfig, watchConfig } from '@oclio/morsel';

const myApp = defineConfig({
  name: 'myapp',
  defaults: { port: 3000, host: 'localhost' },
});

const store = await watchConfig(myApp);

store.on('port', (next, prev) => {
  console.log(`port: ${prev} → ${next}`);
});

// Edit ./myapp.config.json → the event fires automatically

store.stop();