Skip to content

Introduction to config ​

A CurvyConfig is the runtime context used by Curvy actions. It owns service clients, storage, reactive account and network state, proving, note synchronization, and lifecycle resources.

Choose a constructor ​

ConstructorUse it forDefaults
createBrowserCurvyConfigBrowser applicationsIndexedDB, session restoration, ambient config
createServerCurvyConfigServers and multi-tenant processesIn-memory storage, no keystore, no ambient config
createCurvyConfigCustom runtimes and testsExplicit control over every adapter

Explicit config ​

Pass config to actions in tests, servers, and applications that can host more than one Curvy instance.

ts
const balances = await getBalances({ config });

This makes ownership and lifecycle unambiguous and prevents one request from reading another request's ambient state.

Ambient config ​

Browser constructors register the new config as the ambient default. A single-instance browser application may omit it from subsequent calls.

ts
await createBrowserCurvyConfig();
const balances = await getBalances();

Prefer explicit config in shared libraries even when the host application uses the ambient form.

State and subscriptions ​

config.state is the current serializable snapshot. config.subscribe observes changes without coupling the SDK to a UI framework. Higher-level event actions such as on are useful for lifecycle events.

Lifecycle ​

Always call destroyConfig when a config's owner is finished with it.

ts
await config.destroy();

Creating a replacement ambient config does not destroy the previous one automatically.

Reading config state ​