Configurate<S> class is the central object you interact with in tauri-plugin-configurate. You instantiate it once per configuration target — providing a schema, a file name, a base directory, and a storage provider — and then call its methods to create, load, save, patch, reset, export, import, validate, and watch your config. The generic parameter S is the schema type returned by defineConfig(), which flows through every method signature to give you end-to-end type safety.
Constructor
Schema object returned by
defineConfig(). The type parameter S is inferred from this value and propagates through all method return types.Name of the config file, including its extension (for example
"app.json" or "settings.toml"). Must be a single filename — forward slashes (/) and back slashes (\) are not allowed. The values "." and ".." are also rejected.A Tauri
BaseDirectory enum value that determines the root location on disk. Import BaseDirectory from @tauri-apps/api/path or from tauri-plugin-configurate-api, which re-exports it.A storage provider returned by one of
JsonProvider(), YmlProvider(), TomlProvider(), or BinaryProvider(). The provider controls the file format and optional encryption.Optional path customization object.
Controls when schema validation runs. All three fields default to
false.Default values merged into loaded data when keys are absent from the stored file. Defaults are applied after migrations run.
Current schema version number. When provided, tauri-plugin-configurate stores a
__configurate_version__ field alongside your data and uses it to detect when migrations are needed.Ordered list of migration steps applied when loading data whose stored version is older than
version. Each step describes a single version increment. Migrations run automatically on load(); if any migration runs, the migrated data is auto-saved back to storage.When
true, rolling backup files (.bak1, .bak2, .bak3) are written before each destructive operation and removed automatically when the application exits. Defaults to false.Quick-start example
Instance Methods
create(data)
Creates a new config file on disk and returns a lazy builder you chain before executing.Full config object whose shape must match the schema. All required fields must be present.
A chainable builder. Call
.run() to execute, .lock(opts).run() to also store keyring fields, or .unlock(opts) to store keyring fields and immediately return the unlocked result.load()
Loads an existing config file from disk. Keyring-protected fields come back asnull in the locked result unless you call .unlock().
A chainable builder. Chain
.run() for a locked result, or .unlock(opts) to populate keyring fields.When
defaults or migrations are configured, they are applied automatically during load() before returning data to you.save(data)
Fully overwrites the existing config file with the provided data. Every field is replaced; this is not a merge operation.Complete replacement data for the config file.
A chainable builder with
.run(), .lock(opts).run(), and .unlock(opts).patch(partial)
Deep-merges a partial object into the existing config. Only keys you supply are updated; all other keys remain unchanged. Uses JSON Merge Patch semantics (RFC 7396): setting a key tonull writes null to that field.
Partial config object. Only present keys are written.
A chainable builder with
.run(), .lock(opts).run(), .createIfMissing(), and .unlock(opts).reset(data)
Deletes the existing config and re-creates it from scratch with the provided data. Equivalent todelete() followed by create(), but performed atomically on the Rust side.
Full replacement data for the re-created config.
A chainable builder with
.run(), .lock(opts).run(), and .unlock(opts).delete(keyringOpts?)
Deletes the config file from disk. If the schema has keyring fields and you supplykeyringOpts, the corresponding keyring entries are removed from the OS keyring as well.
When provided, removes associated keyring entries. Omit if your schema has no
keyring() fields, or if you intentionally want to leave keyring entries intact.exists()
Checks whether the config file currently exists on disk.true if the file exists, false otherwise.list()
Lists config file names in the resolved root directory. For file-based providers, files are filtered to the provider’s extension;.bak* and temporary files are excluded. For SQLite, all config_key values in the table are returned.
Array of file names (including their extension) found in the root directory.
exportAs(format, keyringOpts?)
Serializes the current config data to a string in the requested format. Useful for backup, clipboard sharing, or cross-format migration.Target serialization format for the exported string.
When provided, keyring fields are unlocked and included in the export. Omit to export with keyring fields absent.
Serialized config string in the requested format.
importFrom(content, format, keyringOpts?)
Parses a serialized config string and writes it to storage, replacing the current config entirely.Serialized config string to import.
Format of the
content string.Required when the schema includes
keyring() fields and the import data contains values for those fields.validate(data)
Validates a complete config object against the schema without writing anything to disk. Throws a descriptive error if validation fails.Full config data to validate.
validatePartial(data)
Validates a partial config object against the schema. Only keys that are present indata are checked; absent keys do not cause validation to fail.
Partial config data to validate.
onChange(callback)
Registers a callback that fires whenever this config is changed by any operation (create, save, patch, delete, reset, import). Changes originating from external processes are reported by watchExternal() instead.
Function invoked with a
ConfigChangeEvent whenever the config changes.A synchronous unlisten function. Call it when you no longer need the listener to avoid memory leaks.
watchExternal(callback)
Watches the config file for changes made by processes outside your application. Only available for file-based providers; calling this with a non-file provider throws an error.Function invoked when an external change is detected. The
event.operation value will be "external_change".An async stop function. Await it to unregister the file watcher on the Rust side and remove the JavaScript listener.
Static Methods
The three static batch methods let you load, save, or patch multiple configs in a single IPC round-trip, significantly reducing overhead when you manage several config files.Configurate.loadAll(entries)
Loads multiple configs in one IPC call. Post-load processing (defaults, migrations) is applied to each entry individually after the batch returns.Array of
{ id: string; config: Configurate<any> } objects. Each id must be unique within the batch.A builder with
.unlock(id, opts), .unlockAll(opts), and .run().Configurate.saveAll(entries)
Saves multiple configs in one IPC call.Array of
{ id: string; config: Configurate<any>; data: unknown } objects.A builder with
.lock(id, opts), .lockAll(opts), and .run().Configurate.patchAll(entries)
Patches multiple configs in one IPC call.Array of
{ id: string; config: Configurate<any>; data: unknown } objects where data is a partial config.A builder with
.lock(id, opts), .lockAll(opts), and .run().