Setup
The examples throughout this guide share a singleConfigurate instance. Define your schema and construct the instance once — typically in a dedicated module that you import wherever you need config access.
create(data)
config.create(data) writes a brand-new config file to disk. It returns a LazyConfigEntry that you finish by chaining one of three terminal methods before awaiting.
| Terminal method | Description | Returns |
|---|---|---|
.lock(keyringOpts).run() | Stores keyring secrets, returns locked data | Promise<LockedConfig<S>> |
.unlock(keyringOpts) | Stores keyring secrets, returns unlocked data | Promise<UnlockedConfig<S>> |
.run() | Runs without keyring (schemas with no keyring() fields only) | Promise<LockedConfig<S>> |
load()
config.load() reads an existing config file from disk. Keyring-protected fields are returned as null in the locked form; call .unlock() to populate them from the OS keyring.
LockedConfig and later decide you need the secrets, you can unlock it without loading from disk again:
Load the config
Call
config.load().run() to read the file from disk. This is fast and
does not touch the OS keyring.Unlock when you need secrets
Call
locked.unlock(KEYRING) (or config.load().unlock(KEYRING) directly)
only when your code actually needs the secret values. Minimising time that
plaintext secrets live in memory is good practice.save(data)
config.save(data) completely overwrites an existing config file with the data you provide. Every field — including keyring-protected ones — is replaced.
create() work here: .lock(opts).run(), .unlock(opts), and .run() (for keyring-free schemas).
delete(keyringOpts?)
config.delete() removes the config file from disk. When you pass KeyringOptions, it also purges all associated keyring entries for that config so no orphaned secrets are left behind.
exists()
config.exists() returns a boolean indicating whether the config file is present on disk. Use this to decide whether to call create() or load() on first launch.
list()
config.list() scans the root directory and returns the file names of all configs stored by the same provider. Backup files and temporary files are excluded automatically.
reset(data)
config.reset(data) is a convenience operation that deletes the existing config and immediately re-creates it with the data you supply — all in a single IPC call. It is equivalent to delete() followed by create(), but atomic from the plugin’s perspective.
create() and save(), reset() supports .lock(opts).run(), .unlock(opts), and .run() as terminal methods.