---
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/sdks/capacitor/libsql.png
---

<!doctype html> 

[Skip to content ](#capacitor-libsql-plugin) 

[🔐 Introducing the **Capacitor Vault** plugin — store secrets behind biometrics or a device passcode. ](/blog/announcing-the-capacitor-vault-plugin/) 

* [ SDKs ](/docs/sdks/)
* [ Formbricks ](/docs/sdks/capacitor/formbricks/)
* [ Geocoder ](/docs/sdks/capacitor/geocoder/)
* [ Google Sign-In ](/docs/sdks/capacitor/google-sign-in/)
* [ Grafana Faro ](/docs/sdks/capacitor/grafana-faro/)
* [ Gyroscope ](/docs/sdks/capacitor/gyroscope/)
* [ Haptics ](/docs/sdks/capacitor/haptics/)
* [ Home Indicator ](/docs/sdks/capacitor/home-indicator/)
* [ In-App Browser ](/docs/sdks/capacitor/in-app-browser/)
* [ Install Referrer ](/docs/sdks/capacitor/install-referrer/)
* [ Keep Awake ](/docs/sdks/capacitor/keep-awake/)
* libSQL [ libSQL ](/docs/sdks/capacitor/libsql/)
* [ Usage ](#usage)
* [ API ](#api)
* [ Type Aliases ](#type-aliases)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)
* [ Light Sensor ](/docs/sdks/capacitor/light-sensor/)
* [ Live Update ](/docs/sdks/capacitor/live-update/)
* [ Localization ](/docs/sdks/capacitor/localization/)
* [ Mail Composer ](/docs/sdks/capacitor/mail-composer/)
* [ Managed Configurations ](/docs/sdks/capacitor/managed-configurations/)
* [ Maps Launcher ](/docs/sdks/capacitor/maps-launcher/)
* [ Media Session ](/docs/sdks/capacitor/media-session/)
* [ ML Kit ](/docs/sdks/capacitor/mlkit/)
* [ Navigation Bar ](/docs/sdks/capacitor/navigation-bar/)
* [ Network ](/docs/sdks/capacitor/network/)
* [ NFC ](/docs/sdks/capacitor/nfc/)
* [ Node.js ](/docs/sdks/capacitor/nodejs/)
* [ OAuth ](/docs/sdks/capacitor/oauth/)
* [ Passkeys ](/docs/sdks/capacitor/passkeys/)
* [ Password Autofill ](/docs/sdks/capacitor/password-autofill/)
* [ PDF Generator ](/docs/sdks/capacitor/pdf-generator/)
* [ PDF Viewer ](/docs/sdks/capacitor/pdf-viewer/)
* [ Pedometer ](/docs/sdks/capacitor/pedometer/)
* [ Permissions ](/docs/sdks/capacitor/permissions/)
* [ Phone Dialer ](/docs/sdks/capacitor/phone-dialer/)
* [ Photo Editor ](/docs/sdks/capacitor/photo-editor/)
* [ Photo Manipulator ](/docs/sdks/capacitor/photo-manipulator/)
* [ PixLive ](/docs/sdks/capacitor/pixlive/)
* [ PostHog ](/docs/sdks/capacitor/posthog/)
* [ Printer ](/docs/sdks/capacitor/printer/)
* [ Privacy Screen ](/docs/sdks/capacitor/privacy-screen/)
* [ Proximity Sensor ](/docs/sdks/capacitor/proximity-sensor/)
* [ Purchases ](/docs/sdks/capacitor/purchases/)
* [ RealtimeKit ](/docs/sdks/capacitor/realtimekit/)
* [ Root Detection ](/docs/sdks/capacitor/root-detection/)
* [ Screen Brightness ](/docs/sdks/capacitor/screen-brightness/)
* [ Screen Orientation ](/docs/sdks/capacitor/screen-orientation/)
* [ Screen Reader ](/docs/sdks/capacitor/screen-reader/)
* [ Screenshot ](/docs/sdks/capacitor/screenshot/)
* [ Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [ Settings Launcher ](/docs/sdks/capacitor/settings-launcher/)
* [ Shake ](/docs/sdks/capacitor/shake/)
* [ Silent Mode ](/docs/sdks/capacitor/silent-mode/)
* [ SIM ](/docs/sdks/capacitor/sim/)
* [ SMS Composer ](/docs/sdks/capacitor/sms-composer/)
* [ Speech Recognition ](/docs/sdks/capacitor/speech-recognition/)
* [ Speech Synthesis ](/docs/sdks/capacitor/speech-synthesis/)
* [ Share Target ](/docs/sdks/capacitor/share-target/)
* [ Square Mobile Payments ](/docs/sdks/capacitor/square-mobile-payments/)
* [ SQLite ](/docs/sdks/capacitor/sqlite/)
* [ Superwall ](/docs/sdks/capacitor/superwall/)
* [ System WebView ](/docs/sdks/capacitor/system-webview/)
* [ Text Interaction ](/docs/sdks/capacitor/text-interaction/)
* [ Text Zoom ](/docs/sdks/capacitor/text-zoom/)
* [ Thermal State ](/docs/sdks/capacitor/thermal-state/)
* [ Toast ](/docs/sdks/capacitor/toast/)
* [ Torch ](/docs/sdks/capacitor/torch/)
* [ Vault ](/docs/sdks/capacitor/vault/)
* [ Volume ](/docs/sdks/capacitor/volume/)
* [ Wallet ](/docs/sdks/capacitor/wallet/)
* [ Wifi ](/docs/sdks/capacitor/wifi/)
* [ Zip ](/docs/sdks/capacitor/zip/)
* [ Cordova ](/docs/sdks/cordova/)
* [ Cloud ](/docs/cloud/)
* [ Integrations ](/docs/cloud/live-updates/integrations/)
* Concepts
* Reference
* [ Troubleshooting ](/docs/cloud/live-updates/troubleshooting/)
* [ FAQ ](/docs/cloud/live-updates/faq/)
* [ Native Builds ](/docs/cloud/native-builds/)
* [ Set Up Environments ](/docs/cloud/native-builds/environments/)
* [ Overwrite Native Configurations ](/docs/cloud/native-builds/native-configurations/)
* [ Auto-Increment Build Numbers ](/docs/cloud/native-builds/auto-incrementing-build-numbers/)
* [ Configure the Web Build Script ](/docs/cloud/native-builds/web-build-script/)
* [ Build from a Monorepo ](/docs/cloud/native-builds/monorepo/)
* [ Use pnpm, Yarn, or bun ](/docs/cloud/native-builds/package-managers/)
* [ Install Private npm Packages ](/docs/cloud/native-builds/npm-private-registry/)
* [ Override the Java Version ](/docs/cloud/native-builds/override-java-version/)
* [ Custom iOS Provisioning Profiles ](/docs/cloud/native-builds/custom-ios-provisioning-profiles/)
* [ Build without Git ](/docs/cloud/native-builds/build-without-git/)
* [ Access Git Behind a Firewall ](/docs/cloud/native-builds/firewall-access/)
* [ Integrations ](/docs/cloud/native-builds/integrations/)
* Reference
* [ Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [ FAQ ](/docs/cloud/native-builds/faq/)
* [ App Store Publishing ](/docs/cloud/app-store-publishing/)
* [ Submit a Build ](/docs/cloud/app-store-publishing/submit-a-build/)
* [ Submit Automatically After a Build ](/docs/cloud/app-store-publishing/submit-automatically/)
* [ Troubleshooting ](/docs/cloud/app-store-publishing/troubleshooting/)
* [ FAQ ](/docs/cloud/app-store-publishing/faq/)
* [ Automations ](/docs/cloud/automations/)
* [ Reference ](/docs/cloud/automations/reference/)
* [ Troubleshooting ](/docs/cloud/automations/troubleshooting/)
* [ FAQ ](/docs/cloud/automations/faq/)
* [ Assist ](/docs/cloud/assist/)
* [ CLI ](/docs/cloud/cli/)
* APIs and SDKs
* [ Webhooks ](/docs/cloud/webhooks/)
* [ Integrations ](/docs/cloud/integrations/)
* Account
* [ Organization ](/docs/cloud/organizations/)
* [ Two-Factor Enforcement ](/docs/cloud/organizations/two-factor-authentication/)
* [ Audit Logs ](/docs/cloud/organizations/audit-logs/)
* [ Billing ](/docs/cloud/organizations/billing/)
* [ License Keys ](/docs/cloud/license-keys/)
* [ AI ](/docs/ai/)
* [ Insiders ](/docs/insiders/)
* [ Billing & Plans ](/docs/insiders/billing-and-plans/)
* [ FAQ ](/docs/insiders/faq/)
* [ License ](https://capawesome.io/legal/eula/)
* [ Support ](/docs/support/)
* [ Contributing ](/docs/contributing/)
* Contributing code
* [ Code of Conduct ](/docs/contributing/code-of-conduct/)
* [ Questions ](https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/participating-in-a-discussion#creating-a-discussion)
* [ Blog ](/blog/)
* Categories

* [ Usage ](#usage)
* [ API ](#api)
* [ Type Aliases ](#type-aliases)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Newsletter ](#newsletter)

# Capacitor libSQL Plugin[¶](#capacitor-libsql-plugin "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/) 

## Use Cases[¶](#use-cases "Permanent link")

The libSQL plugin is typically used whenever an app needs a SQL database, for example:

* **Offline-first apps**: Store data in a local database file on the device and synchronize it with a remote server using the `sync(...)` method.
* **Remote databases**: Connect directly to a remote libSQL database, such as one hosted on Turso, using a URL and authentication token.
* **Structured local storage**: Create tables and insert, update, delete, and query data with SQL statements and bound values.
* **Atomic operations**: Group multiple statements into a transaction that can be committed or rolled back as a whole.

## 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")

The following examples show how to connect to local and remote databases, query data, execute insert, update, and delete statements, run statements inside a transaction, and synchronize with a remote server.

### Connect to a local database[¶](#connect-to-a-local-database "Permanent link")

Connect to a local database file on the device. If no file exists at the specified path, a new file is created. If neither a path nor a URL is provided, the plugin creates a new in-memory database. This method must be called before any other methods that interact with the database:

`[](#%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)};
`

### Connect to a remote database[¶](#connect-to-a-remote-database "Permanent link")

Connect to a remote libSQL database using its URL and an authentication token:

`[](#%5F%5Fcodelineno-4-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)const connectToRemoteDatabase = async () => {
[](#%5F%5Fcodelineno-4-4)  const { connectionId } = await Libsql.connect({
[](#%5F%5Fcodelineno-4-5)    url: 'libsql://your-database-url.turso.io',
[](#%5F%5Fcodelineno-4-6)    authToken: 'your-auth-token',
[](#%5F%5Fcodelineno-4-7)  });
[](#%5F%5Fcodelineno-4-8)  console.log('Connected to remote database with ID:', connectionId);
[](#%5F%5Fcodelineno-4-9)};
`

### Query data[¶](#query-data "Permanent link")

Execute a `SELECT` statement and retrieve the result set:

`[](#%5F%5Fcodelineno-5-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-5-2)
[](#%5F%5Fcodelineno-5-3)const query = async () => {
[](#%5F%5Fcodelineno-5-4)  const result = await Libsql.query({
[](#%5F%5Fcodelineno-5-5)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-5-6)    statement: 'SELECT * FROM my_table',
[](#%5F%5Fcodelineno-5-7)  });
[](#%5F%5Fcodelineno-5-8)  console.log('Query result:', result.rows);
[](#%5F%5Fcodelineno-5-9)};
`

### Insert, update, and delete data[¶](#insert-update-and-delete-data "Permanent link")

Execute any SQL statement, including `INSERT`, `UPDATE`, `DELETE`, and `CREATE TABLE`, optionally with bound values:

`[](#%5F%5Fcodelineno-6-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-6-2)
[](#%5F%5Fcodelineno-6-3)const execute = async () => {
[](#%5F%5Fcodelineno-6-4)  await Libsql.execute({
[](#%5F%5Fcodelineno-6-5)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-6-6)    statement: 'INSERT INTO my_table (column1, column2) VALUES (?, ?)',
[](#%5F%5Fcodelineno-6-7)    values: ['value1', 'value2'],
[](#%5F%5Fcodelineno-6-8)  });
[](#%5F%5Fcodelineno-6-9)  console.log('Insert executed successfully');
[](#%5F%5Fcodelineno-6-10)};
`

### Run multiple statements in a transaction[¶](#run-multiple-statements-in-a-transaction "Permanent link")

Begin a transaction, execute statements as part of it, and either commit or roll back all changes. Transactions are only available on Android:

`[](#%5F%5Fcodelineno-7-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-7-2)
[](#%5F%5Fcodelineno-7-3)const performTransaction = async () => {
[](#%5F%5Fcodelineno-7-4)  const { transactionId } = await Libsql.beginTransaction({
[](#%5F%5Fcodelineno-7-5)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-7-6)  });
[](#%5F%5Fcodelineno-7-7)  try {
[](#%5F%5Fcodelineno-7-8)    await Libsql.execute({
[](#%5F%5Fcodelineno-7-9)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-7-10)      statement: 'UPDATE my_table SET column1 = ? WHERE column2 = ?',
[](#%5F%5Fcodelineno-7-11)      values: ['new_value', 'value2'],
[](#%5F%5Fcodelineno-7-12)      transactionId,
[](#%5F%5Fcodelineno-7-13)    });
[](#%5F%5Fcodelineno-7-14)    await Libsql.commitTransaction({
[](#%5F%5Fcodelineno-7-15)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-7-16)      transactionId,
[](#%5F%5Fcodelineno-7-17)    });
[](#%5F%5Fcodelineno-7-18)    console.log('Transaction committed successfully');
[](#%5F%5Fcodelineno-7-19)  } catch (error) {
[](#%5F%5Fcodelineno-7-20)    await Libsql.rollbackTransaction({
[](#%5F%5Fcodelineno-7-21)      connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-7-22)      transactionId,
[](#%5F%5Fcodelineno-7-23)    });
[](#%5F%5Fcodelineno-7-24)    console.error('Transaction rolled back due to error:', error);
[](#%5F%5Fcodelineno-7-25)  }
[](#%5F%5Fcodelineno-7-26)};
`

### Synchronize with a remote server[¶](#synchronize-with-a-remote-server "Permanent link")

Synchronize the database with the remote server:

`[](#%5F%5Fcodelineno-8-1)import { Libsql } from '@capawesome/capacitor-libsql';
[](#%5F%5Fcodelineno-8-2)
[](#%5F%5Fcodelineno-8-3)const sync = async () => {
[](#%5F%5Fcodelineno-8-4)  await Libsql.sync({
[](#%5F%5Fcodelineno-8-5)    connectionId: 'my-connection-id',
[](#%5F%5Fcodelineno-8-6)  });
[](#%5F%5Fcodelineno-8-7)  console.log('Database synchronized successfully');
[](#%5F%5Fcodelineno-8-8)};
`

## 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-9-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-10-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-11-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-12-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-13-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-14-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-15-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-16-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`

## FAQ[¶](#faq "Permanent link")

### Can I use this plugin with Turso?[¶](#can-i-use-this-plugin-with-turso "Permanent link")

Yes, you can connect to a remote libSQL database hosted on [Turso](https://docs.turso.tech/libsql) by passing the database URL and an authentication token to the `connect(...)` method, as shown in the [usage example](#connect-to-a-remote-database) above.

### Do I need a remote database to use this plugin?[¶](#do-i-need-a-remote-database-to-use-this-plugin "Permanent link")

No, the plugin also works with purely local databases. If you pass a `path` to the `connect(...)` method, the plugin uses a database file on the device and creates it if it does not exist. If you provide neither a path nor a URL, the plugin creates a new in-memory database.

### Are transactions supported?[¶](#are-transactions-supported "Permanent link")

Yes, you can use the `beginTransaction(...)`, `commitTransaction(...)` and `rollbackTransaction(...)` methods to group multiple statements into a transaction. Note that transactions are only available on Android.

### What is the difference between the `query` and `execute` methods?[¶](#what-is-the-difference-between-the-query-and-execute-methods "Permanent link")

The `query(...)` method is used to execute `SELECT` statements and retrieve the result set. The `execute(...)` method is used for any other SQL statement, including `INSERT`, `UPDATE`, `DELETE`, and `CREATE TABLE`, and does not return a result set. Both methods support binding values to the statement.

### How do I keep a local database in sync with a remote server?[¶](#how-do-i-keep-a-local-database-in-sync-with-a-remote-server "Permanent link")

Call the `sync(...)` method with the ID of the connection you want to synchronize. This synchronizes the database with the remote server and is available on Android and iOS.

### Can I use this plugin with Ionic, React, Vue or Angular?[¶](#can-i-use-this-plugin-with-ionic-react-vue-or-angular "Permanent link")

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

## Related Plugins[¶](#related-plugins "Permanent link")

* [SQLite](https://capawesome.io/docs/sdks/capacitor/sqlite/): Access SQLite databases with support for encryption, transactions, and schema migrations.
* [Secure Preferences](https://capawesome.io/docs/sdks/capacitor/secure-preferences/): Securely store key/value pairs such as passwords or tokens.

## 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/).

---

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

July 8, 2026 

Back to top

```json
{"@context": "https://schema.org", "@graph": [{"@type": "TechArticle", "@id": "https://capawesome.io/docs/sdks/capacitor/libsql/#article", "headline": "Capacitor libSQL Plugin for Android & iOS", "name": "Capacitor libSQL Plugin for Android & iOS", "description": "Interact with libSQL databases in your Capacitor app, enabling advanced SQL database features. Supports Android and iOS.", "inLanguage": "en", "url": "https://capawesome.io/docs/sdks/capacitor/libsql/", "mainEntityOfPage": "https://capawesome.io/docs/sdks/capacitor/libsql/", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "about": {"@id": "https://capawesome.io/docs/sdks/capacitor/libsql/#software"}}, {"@type": "SoftwareSourceCode", "@id": "https://capawesome.io/docs/sdks/capacitor/libsql/#software", "name": "Capacitor libSQL Plugin for Android & iOS", "description": "Interact with libSQL databases in your Capacitor app, enabling advanced SQL database features. Supports Android and iOS.", "url": "https://capawesome.io/docs/sdks/capacitor/libsql/", "programmingLanguage": "TypeScript", "runtimePlatform": "Capacitor", "codeRepository": "https://github.com/capawesome-team", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}}]}
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Can I use this plugin with Turso?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, you can connect to a remote libSQL database hosted on Turso by passing the database URL and an authentication token to the connect(...) method, as shown in the usage example above."}}, {"@type": "Question", "name": "Do I need a remote database to use this plugin?", "acceptedAnswer": {"@type": "Answer", "text": "No, the plugin also works with purely local databases. If you pass a path to the connect(...) method, the plugin uses a database file on the device and creates it if it does not exist. If you provide neither a path nor a URL, the plugin creates a new in-memory database."}}, {"@type": "Question", "name": "Are transactions supported?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, you can use the beginTransaction(...), commitTransaction(...) and rollbackTransaction(...) methods to group multiple statements into a transaction. Note that transactions are only available on Android."}}, {"@type": "Question", "name": "What is the difference between the query and execute methods?", "acceptedAnswer": {"@type": "Answer", "text": "The query(...) method is used to execute SELECT statements and retrieve the result set. The execute(...) method is used for any other SQL statement, including INSERT, UPDATE, DELETE, and CREATE TABLE, and does not return a result set. Both methods support binding values to the statement."}}, {"@type": "Question", "name": "How do I keep a local database in sync with a remote server?", "acceptedAnswer": {"@type": "Answer", "text": "Call the sync(...) method with the ID of the connection you want to synchronize. This synchronizes the database with the remote server and is available on Android and iOS."}}, {"@type": "Question", "name": "Can I use this plugin with Ionic, React, Vue or Angular?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects."}}], "url": "https://capawesome.io/docs/sdks/capacitor/libsql/"}
```
