Skip to content

objectSource

objectSource(values, name?): StructuredSource

Defined in: sources.ts:172

A StructuredSource backed by a static, possibly nested object.

This is the structured counterpart to staticSource: where staticSource carries flat string defaults, objectSource carries a nested object (sub-objects, arrays, even functions) that participates in loadConfig’s deep merge. Use it as the defaults layer beneath a configFileSource, so a user’s config file only overrides the keys it sets:

Record<string, unknown>

string = "object"

StructuredSource

sources: [
objectSource({ dev: { port: 3000 }, build: { minify: true } }),
configFileSource({ name: "app" }),
]

The top-level object is shallow-copied so later callers can’t mutate your defaults; nested values are shared by reference (and may include functions, which a deep clone could not preserve).