Function: openLix()

openLix(args): 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.

Parameters

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 })

account.id

LixGenerated<string>

account.name

string

blob?

Blob

Lix file data to initialize the database with.

keyValues?

NewState<LixKeyValue>[]

Set the key values when opening the lix.

Example

const lix = await openLix({ keyValues: [{ key: "lix_sync", value: "false" }] })

providePlugins?

LixPlugin[]

Usecase are lix apps that define their own file format, like inlang (unlike a markdown, csv, or json plugin).

(+) avoids separating app code from plugin code and resulting bundling logic.

(-) such a file format must always be opened with the file format sdk. the file is not portable

Example

const lix = await openLix({ providePlugins: [myPlugin] })

storage?

LixStorageAdapter

Storage adapter for persisting lix data.

Default

InMemoryStorage

Returns

Promise<Lix>

Example

// In-memory (default)
const lix = await openLix({})

// From existing data
const lix = await openLix({ blob: existingLixFile })

// With custom storage adapter
import { MyCustomStorage } from "./my-custom-storage.js"
const lix = await openLix({
  storage: new MyCustomStorage()
})