logo
  • Docs
  • API Reference
    Overview
    Functions
    acceptChangeProposal
    applyChangeSet
    attachConversation
    attachLabel
    commitIsAncestorOf
    commitIsDescendantOf
    createAccount
    createChangeProposal
    createChangeSet
    createCheckpoint
    createConversation
    createConversationMessage
    createHooks
    createLabel
    createLog
    createLspInMemoryEnvironment
    createQuerySync
    createServerProtocolHandler
    createVersion
    createVersionFromCommit
    detachConversation
    detachLabel
    ebEntity
    getTimestamp
    humanId
    mergeVersion
    nanoId
    newLixFile
    nextSequenceNumber
    normalizeDirectoryPath
    normalizeFilePath
    normalizePathSegment
    openLix
    random
    rejectChangeProposal
    selectCommitDiff
    selectVersionDiff
    selectWorkingDiff
    switchAccount
    switchVersion
    transition
    uuidV7
    uuidV7Sync
    validateLixSchema
    validateLixSchemaDefinition
    withWriterKey
    Type Aliases
    Account
    ActiveAccount
    Change
    ChangeAuthor
    DetectedChange
    EntityStateByVersionView
    EntityStateHistoryView
    EntityStateView
    EnvironmentActorHandle
    FromLixSchemaDefinition
    JSONType
    Lix
    LixActiveVersion
    LixChangeProposal
    LixChangeSet
    LixChangeSetElement
    LixCommit
    LixCommitEdge
    LixConversation
    LixConversationMessage
    LixDatabaseSchema
    LixDirectoryDescriptor
    LixEntity
    LixEntityCanonical
    LixEntityConversation
    LixEntityLabel
    LixFile
    LixFileDescriptor
    LixGenerated
    LixHooks
    LixInsertable
    LixKeyValue
    LixLabel
    LixLog
    LixPlugin
    LixSchemaDefinition
    LixSelectable
    LixServerProtocolHandlerContext
    LixUpdateable
    LixVersion
    LixVersionDescriptor
    LixVersionTip
    NewChange
    NewState
    NewStateByVersion
    NewStateByVersionRow
    NewStateRow
    QuerySync
    RenderDiffArgs
    SpawnActorOptions
    State
    StateByVersion
    StateByVersionRow
    StateByVersionRowUpdate
    StateByVersionUpdate
    StateByVersionView
    StateCommitChange
    StateHistory
    StateRow
    StateRowUpdate
    StateUpdate
    StateView
    StateWithTombstonesRow
    StateWithTombstonesView
    StoredSchema
    ToKysely
    Variables
    JSONTypeSchema
    LixAccountSchema
    LixActiveAccountSchema
    LixActiveVersionSchema
    LixChangeAuthorSchema
    LixChangeProposalSchema
    LixChangeSetElementSchema
    LixChangeSetSchema
    LixCommitEdgeSchema
    LixCommitSchema
    LixConversationMessageSchema
    LixConversationSchema
    LixDirectoryDescriptorSchema
    LixFileDescriptorSchema
    LixKeyValueSchema
    LixLabelSchema
    LixLogSchema
    LixSchemaDefinition
    LixStoredSchemaSchema
    LixVersionDescriptorSchema
    LixVersionTipSchema
    mockJsonPlugin
    Classes
    InMemoryEnvironment
    LixObservable
    OpfsSahEnvironment
    Interfaces
    LixEnvironment
    Previous pagenormalizePathSegmentNext pagerandom

    #Function: openLix()

    openLix(args: { account?: { id: LixGenerated<string>; name: string; }; blob?: Blob; environment?: LixEnvironment; keyValues?: NewStateByVersion<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.

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

    #Parameters

    ParameterTypeDescription
    args{ account?: { id: LixGenerated<string>; name: string; }; blob?: Blob; environment?: LixEnvironment; keyValues?: NewStateByVersion<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.idLixGenerated<string>-
    args.account.namestring-
    args.blob?BlobLix file data to initialize the database with.
    args.environment?LixEnvironment-
    args.keyValues?NewStateByVersion<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] });

    #Returns

    Promise<Lix>