Interface: SchemaRegistry
Defined in: src/Mnemonic/types.ts:619
Lookup and registration API for key schemas and migration paths.
Implementations of this interface are passed to MnemonicProvider via the
schemaRegistry option. The provider calls these methods at read and write
time to resolve the correct JSON Schema and migration chain for each
stored value.
In "default" and "strict" modes, callers should treat registry contents
as immutable after provider initialization. The hook caches lookups to keep
read/write hot paths fast. "autoschema" remains mutable to support
inferred schema registration.
Most applications should prefer createSchemaRegistry instead of implementing this interface manually. Manual implementations are mainly for advanced cases such as custom backing stores, dynamic schema discovery, or adapter layers around an existing registry system.
Example
const registry = createSchemaRegistry({
schemas: [
{ key: "settings", version: 1, schema: { type: "object", required: ["theme"] } },
],
migrations: [],
});
<MnemonicProvider namespace="app" schemaRegistry={registry} schemaMode="strict">
<App />
</MnemonicProvider>