Skip to content

LibsqlClient

libSQL adapter for Effect SQL, backed by @libsql/client.

This module provides a LibsqlClient and the generic SQL client service for @libsql/client. It uses Effect SQL's SQLite compiler, supports managed SDK clients or caller-owned live clients, classifies libSQL and SQLite failures as SqlErrors, and provides transaction support with savepoints. Streaming queries are not implemented by this driver.

9 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a scoped libSQL SQL client with transaction support. When given connection options it creates and closes the SDK client; when given liveClient, the caller retains ownership.

Signature

declare function make(options: LibsqlClientConfig): Effect<LibsqlClient, never, Scope | Reactivity>;

Layers

layer

Added in v4.0.0 Source

Creates a layer from a concrete libSQL client configuration, providing both LibsqlClient and SqlClient.

Signature

declare function layer(config: LibsqlClientConfig): Layer<LibsqlClient | SqlClient>;

layerConfig

Added in v4.0.0 Source

Creates a layer from a Config-wrapped libSQL client configuration, providing both LibsqlClient and SqlClient.

Signature

declare const layerConfig: (
config: Config.Wrap<LibsqlClientConfig>,
) => Layer.Layer<LibsqlClient | Client.SqlClient, Config.ConfigError>;

Models

LibsqlClientConfig type

Added in v4.0.0 Source

Configuration for a libSQL client, either by supplying connection options or an existing live libSQL client.

Signature

type LibsqlClientConfig = LibsqlClientConfig.Full | LibsqlClientConfig.Live;

Other

Namespace containing the configuration variants for LibsqlClient.

Services

LibsqlClient

Added in v4.0.0 Source

Service tag for the libSQL client service.

When to use

Use to access or provide a libSQL client through the Effect context.

Signature

declare const LibsqlClient: Service<LibsqlClient, LibsqlClient>;

LibsqlClient interface

Added in v4.0.0 Source

libSQL-backed SQL client service, extending SqlClient with its runtime type marker and client configuration.

Signature

interface LibsqlClient extends SqlClient {
<A extends object = Row>(strings: TemplateStringsArray, ...args: Array<any>): Statement<A>;
(value: string): Identifier;
readonly "~@effect/sql-libsql/LibsqlClient": "~@effect/sql-libsql/LibsqlClient";
readonly config: LibsqlClientConfig;
}

Type IDs

TypeId

Added in v4.0.0 Source

Runtime type identifier used to mark LibsqlClient values.

Signature

declare const TypeId: TypeId;

TypeId type

Added in v4.0.0 Source

Type-level identifier used to mark LibsqlClient values.

Signature

type TypeId = "~@effect/sql-libsql/LibsqlClient";