.run() or .unlock().
Setup
All examples on this page assume a schema andConfigurate instance like the following:
src/lib/config.ts
create
config.create(data) creates a new config file. Pass the full config value as the argument.
Because the schema contains a keyring() field, you must chain .lock(KEYRING) before .run() so the secret is routed to the OS keyring rather than written to disk.
Schemas without
keyring() fields do not require .lock(). Call .run() directly: await config.create({ theme: "dark", language: "en" }).run().load
config.load() reads the stored config file. Without .unlock(), keyring fields come back as null.
save
config.save(data) overwrites the entire config file with new data. Every field is replaced — use patch if you only want to update a subset of keys.
patch
config.patch(partial) deep-merges the provided keys into the stored config. Keys you omit are left unchanged. This follows RFC 7396 JSON Merge Patch semantics: setting a key to null overwrites the stored value; omitting a key leaves it untouched.
delete
config.delete(keyringOpts?) deletes the config file. Pass KeyringOptions to also remove associated keyring entries from the OS keyring.
exists
config.exists() returns a boolean indicating whether the config file is present.
list
config.list() returns the names of all config files in the resolved root directory. For file-based providers, this scans for files matching the provider’s extension; backup files (.bak*) and temp files are excluded. For SQLite, it returns all config_key values in the table.
reset
config.reset(data) deletes the existing config and immediately re-creates it with the data you provide. It is equivalent to calling delete followed by create, but in a single round-trip.
Operation summary
The table below shows which builder methods each operation supports.| Operation | .lock().run() | .run() | .unlock() | .createIfMissing() |
|---|---|---|---|---|
create | Yes | Yes (no keyring) | Yes | No |
load | — | Yes | Yes | No |
save | Yes | Yes (no keyring) | Yes | No |
patch | Yes | Yes | Yes | Yes |
reset | Yes | Yes (no keyring) | Yes | No |
delete | — | Pass KeyringOptions directly | — | No |
exists | — | Direct Promise<boolean> | — | No |
list | — | Direct Promise<string[]> | — | No |