openLix(
args
: {account?
: {id
:LixGenerated
<string
>;name
:string
; };blob?
:Blob
;environment?
:LixEnvironment
;keyValues?
:NewStateAll
<LixKeyValue
>[];providePlugins?
:LixPlugin
[];providePluginsRaw?
:string
[]; }):Promise
<Lix
>
Opens a Lix instance.
Creates an in-memory database by default. If a blob is provided, the database is initialized with that data. If a database is provided, uses that database directly.
Parameter | Type | Description |
---|---|---|
args | { account? : { id : LixGenerated <string >; name : string ; }; blob? : Blob ; environment? : LixEnvironment ; keyValues? : NewStateAll <LixKeyValue >[]; providePlugins? : LixPlugin []; providePluginsRaw? : string []; } | - |
args.account? | { id : LixGenerated <string >; name : string ; } | The account that is opening this lix. Lix will automatically set the active account to the provided account. Example const account = localStorage.getItem("account") const lix = await openLix({ account }) |
args.account.id | LixGenerated <string > | - |
args.account.name | string | - |
args.blob? | Blob | Lix file data to initialize the database with. |
args.environment? | LixEnvironment | - |
args.keyValues? | NewStateAll <LixKeyValue >[] | Set the key values when opening the lix. The lixcol_version_id defaults to the active version. Example const lix = await openLix({ keyValues: [{ key: "lix_sync", value: "false" }] }) |
args.providePlugins? | LixPlugin [] | Provide plugin instances directly (in-process environments only). Use this when executing in the same thread as the engine, e.g. tests or scripts running with InMemoryEnvironment. Plugins supplied this way are not transferable across worker boundaries. Prefer providePluginsRaw when the environment can access bundled plugin source (for example via ?raw import). Raw strings load on the target thread and work in both workers and main-thread contexts, but are usually unavailable in unit tests. Example const lix = await openLix({ providePlugins: [jsonPlugin] }) |
args.providePluginsRaw? | string [] | Provide plugins as stringified ESM modules. This is the portable format for worker or cross-thread environments where functions cannot be structured cloned. Each string is evaluated via loadPluginFromString inside the target environment. Example const jsonPlugin = await fetch("/plugins/json.js").then((res) => res.text()); const lix = await openLix({ providePluginsRaw: [jsonPlugin] }); |
Promise
<Lix
>