---
description: Interact with libSQL databases in your Capacitor app, enabling advanced SQL database features. Supports Android and iOS.
title: Capacitor libSQL Plugin for Android & iOS - Capawesome
image: https://capawesome.io/docs/assets/images/social/plugins/libsql.png
---

[ Skip to content](#capawesomecapacitor-libsql) 

[ 🎉 Introducing **Capawesome Platform** — one platform for Live Updates, Native Builds, App Store Publishing, and Insider SDKs.](https://capawesome.io) 

* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* libSQL [  libSQL ](/docs/plugins/libsql/)
* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)
* [  Live Update ](/docs/plugins/live-update/)
* [  Managed Configurations ](/docs/plugins/managed-configurations/)
* [  Media Session ](/docs/plugins/media-session/)
* [  ML Kit ](/docs/plugins/mlkit/)
* [  NFC ](/docs/plugins/nfc/)
* [  OAuth ](/docs/plugins/oauth/)
* [  Pedometer ](/docs/plugins/pedometer/)
* [  Photo Editor ](/docs/plugins/photo-editor/)
* [  PostHog ](/docs/plugins/posthog/)
* [  Printer ](/docs/plugins/printer/)
* [  Purchases ](/docs/plugins/purchases/)
* [  RealtimeKit ](/docs/plugins/realtimekit/)
* [  Screen Orientation ](/docs/plugins/screen-orientation/)
* [  Screenshot ](/docs/plugins/screenshot/)
* [  Secure Preferences ](/docs/plugins/secure-preferences/)
* [  Speech Recognition ](/docs/plugins/speech-recognition/)
* [  Speech Synthesis ](/docs/plugins/speech-synthesis/)
* [  Share Target ](/docs/plugins/share-target/)
* [  Square Mobile Payments ](/docs/plugins/square-mobile-payments/)
* [  SQLite ](/docs/plugins/sqlite/)
* [  Superwall ](/docs/plugins/superwall/)
* [  Torch ](/docs/plugins/torch/)
* [  Wifi ](/docs/plugins/wifi/)
* [  Zip ](/docs/plugins/zip/)
* [  Cloud ](/docs/cloud/)
* [  Live Updates ](/docs/cloud/live-updates/)
* Advanced
* Integrations
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Configuration ](/docs/cloud/native-builds/configuration/)
* [  Environments ](/docs/cloud/native-builds/environments/)
* Guides
* [  Sample Projects ](/docs/cloud/native-builds/sample-projects/)
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  Automations ](/docs/cloud/automations/)
* [  Assist ](/docs/cloud/assist/)
* Account
* Organizations
* [  Organization and User Management ](/docs/cloud/organizations/memberships/)
* [  Single Sign-On (SSO) ](/docs/cloud/organizations/sso/)
* [  Teams ](/docs/cloud/organizations/teams/)
* [  Two-Factor Authentication ](/docs/cloud/organizations/two-factor-authentication/)
* [  Integrations ](/docs/cloud/integrations/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Pricing ](https://capawesome.io/pricing/)
* [  FAQ ](/docs/cloud/faq/)
* [  Support ](/docs/cloud/support/)
* [  Contributing ](/docs/contributing/)
* [  LLMs ](/docs/llms/)
* [  Insiders ](/docs/insiders/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/insiders/support/)
* [  FAQ ](/docs/insiders/faq/)
* [  Blog ](/blog/)
* Categories

* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)

# @capawesome/capacitor-libsql[¶](#capawesomecapacitor-libsql "Permanent link")

Capacitor plugin for [libSQL](https://docs.turso.tech/libsql) databases.[1](#fn:1)

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](../../assets/external/cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.69628c3f.png) ](https://cloud.capawesome.io/) 

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 0.2.x          | \>=8.x.x          | Active support |
| 0.1.x          | 7.x.x             | Deprecated     |

## Installation[¶](#installation "Permanent link")

You can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-0-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-1-1) Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-libsql` plugin in my project.
 ``

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

`[](#%5F%5Fcodelineno-2-1)npm install @capawesome/capacitor-libsql
[](#%5F%5Fcodelineno-2-2)npx cap sync
`

### Android[¶](#android "Permanent link")

#### Variables[¶](#variables "Permanent link")

If needed, you can define the following project variable in your app's `variables.gradle` file to change the default version of the dependency:

* `$libsqlVersion` version of `tech.turso.libsql:libsql` (default: `0.1.2`)

This can be useful if you encounter dependency conflicts with other plugins in your project.

## Usage[¶](#usage "Permanent link")

`[](#%5F%5Fcodelineno-3-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-3-2)
[](#%5F%5Fcodelineno-3-3)const connectToLocalDatabase = async () => {
[](#%5F%5Fcodelineno-3-4)  const { connectionId } = await Libsql.connect({
[](#%5F%5Fcodelineno-3-5)    path: 'database.db',
[](#%5F%5Fcodelineno-3-6)  });
[](#%5F%5Fcodelineno-3-7)  console.log('Connected to database with ID:', connectionId);
[](#%5F%5Fcodelineno-3-8)};
[](#%5F%5Fcodelineno-3-9)
[](#%5F%5Fcodelineno-3-10)const connectToRemoteDatabase = async () => {
[](#%5F%5Fcodelineno-3-11)  const { connectionId } = await Libsql.connect({
[](#%5F%5Fcodelineno-3-12)    url: 'libsql://your-database-url.turso.io',
[](#%5F%5Fcodelineno-3-13)    authToken: 'your-auth-token',
[](#%5F%5Fcodelineno-3-14)  });
[](#%5F%5Fcodelineno-3-15)  console.log('Connected to remote database with ID:', connectionId);
[](#%5F%5Fcodelineno-3-16)};
[](#%5F%5Fcodelineno-3-17)
[](#%5F%5Fcodelineno-3-18)const query = async () => {
[](#%5F%5Fcodelineno-3-19)  const result = await Libsql.query({
[](#%5F%5Fcodelineno-3-20)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-21)    statement: 'SELECT * FROM my_table',
[](#%5F%5Fcodelineno-3-22)  });
[](#%5F%5Fcodelineno-3-23)  console.log('Query result:', result.rows);
[](#%5F%5Fcodelineno-3-24)};
[](#%5F%5Fcodelineno-3-25)
[](#%5F%5Fcodelineno-3-26)const execute = async () => {
[](#%5F%5Fcodelineno-3-27)  await Libsql.execute({
[](#%5F%5Fcodelineno-3-28)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-29)    statement: 'INSERT INTO my_table (column1, column2) VALUES (?, ?)',
[](#%5F%5Fcodelineno-3-30)    values: ['value1', 'value2'],
[](#%5F%5Fcodelineno-3-31)  });
[](#%5F%5Fcodelineno-3-32)  console.log('Insert executed successfully');
[](#%5F%5Fcodelineno-3-33)};
[](#%5F%5Fcodelineno-3-34)
[](#%5F%5Fcodelineno-3-35)const performTransaction = async () => {
[](#%5F%5Fcodelineno-3-36)  const { transactionId } = await Libsql.beginTransaction({
[](#%5F%5Fcodelineno-3-37)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-38)  });
[](#%5F%5Fcodelineno-3-39)  try {
[](#%5F%5Fcodelineno-3-40)    await Libsql.execute({
[](#%5F%5Fcodelineno-3-41)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-42)      statement: 'UPDATE my_table SET column1 = ? WHERE column2 = ?',
[](#%5F%5Fcodelineno-3-43)      values: ['new_value', 'value2'],
[](#%5F%5Fcodelineno-3-44)      transactionId,
[](#%5F%5Fcodelineno-3-45)    });
[](#%5F%5Fcodelineno-3-46)    await Libsql.commitTransaction({
[](#%5F%5Fcodelineno-3-47)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-48)      transactionId,
[](#%5F%5Fcodelineno-3-49)    });
[](#%5F%5Fcodelineno-3-50)    console.log('Transaction committed successfully');
[](#%5F%5Fcodelineno-3-51)  } catch (error) {
[](#%5F%5Fcodelineno-3-52)    await Libsql.rollbackTransaction({
[](#%5F%5Fcodelineno-3-53)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-54)      transactionId,
[](#%5F%5Fcodelineno-3-55)    });
[](#%5F%5Fcodelineno-3-56)    console.error('Transaction rolled back due to error:', error);
[](#%5F%5Fcodelineno-3-57)  }
[](#%5F%5Fcodelineno-3-58)};
[](#%5F%5Fcodelineno-3-59)
[](#%5F%5Fcodelineno-3-60)const sync = async () => {
[](#%5F%5Fcodelineno-3-61)  await Libsql.sync({
[](#%5F%5Fcodelineno-3-62)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-3-63)  });
[](#%5F%5Fcodelineno-3-64)  console.log('Database synchronized successfully');
[](#%5F%5Fcodelineno-3-65)};
`

## API[¶](#api "Permanent link")

* [beginTransaction(...)](#begintransaction)
* [commitTransaction(...)](#committransaction)
* [connect(...)](#connect)
* [execute(...)](#execute)
* [executeBatch(...)](#executebatch)
* [query(...)](#query)
* [rollbackTransaction(...)](#rollbacktransaction)
* [sync(...)](#sync)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

### beginTransaction(...)[¶](#begintransaction "Permanent link")

`[](#%5F%5Fcodelineno-4-1)beginTransaction(options: BeginTransactionOptions) => Promise<BeginTransactionResult>
`

Begin a transaction on the specified database connection.

Only available on Android.

| Param       | Type                                                |
| ----------- | --------------------------------------------------- |
| **options** | [BeginTransactionOptions](#begintransactionoptions) |

**Returns:** `Promise<[BeginTransactionResult](#begintransactionresult)>`

**Since:** 0.0.0

---

### commitTransaction(...)[¶](#committransaction "Permanent link")

`[](#%5F%5Fcodelineno-5-1)commitTransaction(options: CommitTransactionOptions) => Promise<void>
`

Commit the current transaction on the specified database connection.

Only available on Android.

| Param       | Type                                                  |
| ----------- | ----------------------------------------------------- |
| **options** | [CommitTransactionOptions](#committransactionoptions) |

**Since:** 0.0.0

---

### connect(...)[¶](#connect "Permanent link")

`[](#%5F%5Fcodelineno-6-1)connect(options: ConnectOptions) => Promise<ConnectResult>
`

Connect to a database.

This method must be called before any other methods that interact with the database.

| Param       | Type                              |
| ----------- | --------------------------------- |
| **options** | [ConnectOptions](#connectoptions) |

**Returns:** `Promise<[ConnectResult](#connectresult)>`

**Since:** 0.0.0

---

### execute(...)[¶](#execute "Permanent link")

`[](#%5F%5Fcodelineno-7-1)execute(options: ExecuteOptions) => Promise<void>
`

Execute a single SQL statement on the specified database connection.

This method can be used to execute any SQL statement, including`INSERT`, `UPDATE`, `DELETE`, and `CREATE TABLE`.

| Param       | Type                              |
| ----------- | --------------------------------- |
| **options** | [ExecuteOptions](#executeoptions) |

**Since:** 0.0.0

---

### executeBatch(...)[¶](#executebatch "Permanent link")

`[](#%5F%5Fcodelineno-8-1)executeBatch(options: ExecuteBatchOptions) => Promise<void>
`

Execute a batch of SQL statements on the specified database connection.

This method can be used to execute multiple SQL statements in a single call.

| Param       | Type                                        |
| ----------- | ------------------------------------------- |
| **options** | [ExecuteBatchOptions](#executebatchoptions) |

**Since:** 0.0.0

---

### query(...)[¶](#query "Permanent link")

`[](#%5F%5Fcodelineno-9-1)query(options: QueryOptions) => Promise<QueryResult>
`

Query the database and return the result set.

This method can be used to execute `SELECT` statements and retrieve the result set.

| Param       | Type                          |
| ----------- | ----------------------------- |
| **options** | [QueryOptions](#queryoptions) |

**Returns:** `Promise<[QueryResult](#queryresult)>`

**Since:** 0.0.0

---

### rollbackTransaction(...)[¶](#rollbacktransaction "Permanent link")

`[](#%5F%5Fcodelineno-10-1)rollbackTransaction(options: RollbackTransactionOptions) => Promise<void>
`

Rollback the current transaction on the specified database connection.

This method will undo all changes made in the current transaction.

Only available on Android.

| Param       | Type                                                      |
| ----------- | --------------------------------------------------------- |
| **options** | [RollbackTransactionOptions](#rollbacktransactionoptions) |

**Since:** 0.0.0

---

### sync(...)[¶](#sync "Permanent link")

`[](#%5F%5Fcodelineno-11-1)sync(options: SyncOptions) => Promise<void>
`

Synchronize the database with the remote server.

Available on iOS and Android.

| Param       | Type                        |
| ----------- | --------------------------- |
| **options** | [SyncOptions](#syncoptions) |

**Since:** 0.0.0

---

### Interfaces[¶](#interfaces "Permanent link")

#### BeginTransactionResult[¶](#begintransactionresult "Permanent link")

| Prop              | Type   | Description                                 | Since |
| ----------------- | ------ | ------------------------------------------- | ----- |
| **transactionId** | string | The ID of the transaction that was started. | 0.0.0 |

#### BeginTransactionOptions[¶](#begintransactionoptions "Permanent link")

| Prop             | Type   | Description                                           | Since |
| ---------------- | ------ | ----------------------------------------------------- | ----- |
| **connectionId** | string | The ID of the connection to begin the transaction on. | 0.0.0 |

#### CommitTransactionOptions[¶](#committransactionoptions "Permanent link")

| Prop              | Type   | Description                                            | Since |
| ----------------- | ------ | ------------------------------------------------------ | ----- |
| **connectionId**  | string | The ID of the connection to commit the transaction on. | 0.0.0 |
| **transactionId** | string | The ID of the transaction to commit.                   | 0.0.0 |

#### ConnectResult[¶](#connectresult "Permanent link")

| Prop             | Type   | Description               | Since |
| ---------------- | ------ | ------------------------- | ----- |
| **connectionId** | string | The ID of the connection. | 0.0.0 |

#### ConnectOptions[¶](#connectoptions "Permanent link")

| Prop          | Type   | Description                                                                                                                                                                                                             | Since |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **authToken** | string | The authentication token for the database. This is required for connecting to a remote database. If the database is local (i.e., a file on the device), this can be omitted.                                            | 0.0.0 |
| **path**      | string | The path to the database file. If no path or URL is provided, the plugin will create a new in-memory database. If no file exists at the specified path, a new file will be created.                                     | 0.0.0 |
| **url**       | string | The URL of the database. This can be used to connect to a remote database. If the URL is provided, the authToken must also be provided. If no path or URL is provided, the plugin will create a new in-memory database. | 0.0.0 |

#### ExecuteOptions[¶](#executeoptions "Permanent link")

| Prop              | Type      | Description                                                                 | Since |
| ----------------- | --------- | --------------------------------------------------------------------------- | ----- |
| **connectionId**  | string    | The ID of the connection to execute the SQL statement on.                   | 0.0.0 |
| **statement**     | string    | The SQL statement to execute.                                               | 0.0.0 |
| **transactionId** | string    | The transaction ID to use for the SQL statement. Only available on Android. | 0.0.0 |
| **values**        | Value\[\] | The values to bind to the SQL statement.                                    | 0.0.0 |

#### ExecuteBatchOptions[¶](#executebatchoptions "Permanent link")

| Prop             | Type          | Description                                       | Since |
| ---------------- | ------------- | ------------------------------------------------- | ----- |
| **connectionId** | string        | The ID of the connection to execute the batch on. | 0.0.0 |
| **statement**    | string\[\]    | The SQL statements to execute in the batch.       | 0.0.0 |
| **values**       | Value\[\]\[\] | The values to bind to the SQL statements.         | 0.0.0 |

#### QueryResult[¶](#queryresult "Permanent link")

| Prop     | Type          | Description                       | Since |
| -------- | ------------- | --------------------------------- | ----- |
| **rows** | Value\[\]\[\] | The values returned by the query. | 0.0.0 |

#### QueryOptions[¶](#queryoptions "Permanent link")

| Prop              | Type      | Description                                                         | Since |
| ----------------- | --------- | ------------------------------------------------------------------- | ----- |
| **connectionId**  | string    | The ID of the connection to query.                                  | 0.0.0 |
| **statement**     | string    | The SQL statement to execute.                                       | 0.0.0 |
| **transactionId** | string    | The transaction ID to use for the query. Only available on Android. | 0.0.0 |
| **values**        | Value\[\] | The values to bind to the SQL statement.                            | 0.0.0 |

#### RollbackTransactionOptions[¶](#rollbacktransactionoptions "Permanent link")

| Prop              | Type   | Description                                              | Since |
| ----------------- | ------ | -------------------------------------------------------- | ----- |
| **connectionId**  | string | The ID of the connection to rollback the transaction on. | 0.0.0 |
| **transactionId** | string | The ID of the transaction to rollback.                   | 0.0.0 |

#### SyncOptions[¶](#syncoptions "Permanent link")

| Prop             | Type   | Description                       | Since |
| ---------------- | ------ | --------------------------------- | ----- |
| **connectionId** | string | The ID of the connection to sync. | 0.0.0 |

### Type Aliases[¶](#type-aliases "Permanent link")

#### Value[¶](#value "Permanent link")

`string | number | null`

---

1. This project is not affiliated with, endorsed by, sponsored by, or approved by CHISELSTRIKE INC. or any of their affiliates or subsidiaries. [↩](#fnref:1 "Jump back to footnote 1 in the text")

May 17, 2026 

 Back to top 