Skip to main content

Recipes

Load defaults, then override from a config folder

import { getConfig } from '@quik/core';

// package entrypoints already call getConfig().load(defaults) on import

await getConfig().init('./config', true); // useExistingAsDefault: keep already-loaded defaults as the base

Files in the config folder are merged on top of defaults in read order; the file's basename (without extension) becomes the top-level config key, and any file with index in its name is skipped.

Override a single value at runtime

import { getConfig } from '@quik/core';

getConfig().set('app.name', 'My App');

set builds a nested object from the dotted key and merges it in the same way as load.

Read typed values

import { getConfig } from '@quik/core';

const name = getConfig().string('app.name');
const enabled = getConfig().boolean('communication.email.enabled');
const attempts = getConfig().number('communication.email.retry.attempts', 1);
const emailConfig = getConfig().object('communication.email.config');

Snapshot the compiled defaults

import { getConfig } from '@quik/core';

const defaults = getConfig().defaults();

Returns a deep copy of the defaults captured at construction (or the snapshot taken by the last init(configFolder, true) call).