Skip to main content
@capgo/capacitor-fast-sql Files & Storage Open source

Fast SQL Capacitor plugin

High-performance native SQLite with custom protocol for efficient sync operations and IndexedDB replacement

Install

bun add @capgo/capacitor-fast-sql bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-fast-sql
  • pnpm add @capgo/capacitor-fast-sql
  • yarn add @capgo/capacitor-fast-sql

Guide

How to use Fast SQL in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Fast SQL plugin preview QR code

Using @capgo/capacitor-fast-sql

Fast SQL Plugin for high-performance SQLite database access.

Install

bun add @capgo/capacitor-fast-sql
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

API at a glance

Method Description
connect Initialize the database connection and start the HTTP server.
disconnect Close database connection and stop the HTTP server.
getServerInfo Get the HTTP server port and token for direct communication.
execute Execute a SQL query via Capacitor bridge (for simple queries). For better performance with large datasets, use the HTTP protocol directly via SQLConnection class.
beginTransaction Begin a database transaction.
commitTransaction Commit the current transaction.
rollbackTransaction Rollback the current transaction.
configureWeb Configure web-specific options for the official SQLite Wasm module.

Examples

connect()

Initialize the database connection and start the HTTP server.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });
console.log('Connected on port:', conn.port);

disconnect()

Close database connection and stop the HTTP server.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });

getServerInfo()

Get the HTTP server port and token for direct communication.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });
console.log('Server port:', info.port);

execute()

Execute a SQL query via Capacitor bridge (for simple queries). For better performance with large datasets, use the HTTP protocol directly via SQLConnection class.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

const result = await CapgoCapacitorFastSql.execute({
  database: 'myapp',
  statement: 'SELECT * FROM users WHERE age > ?',
  params: [18]
});
console.log('Rows:', result.rows);

beginTransaction()

Begin a database transaction.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });
// Execute multiple operations
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });

commitTransaction()

Commit the current transaction.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });

The table above lists the 8 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Full reference

Keep going from Using @capgo/capacitor-fast-sql

If you are using Using @capgo/capacitor-fast-sql to plan storage and file handling, connect it with @capgo/capacitor-fast-sql for the implementation detail in @capgo/capacitor-fast-sql, Getting Started for the implementation detail in Getting Started, @capgo/capacitor-data-storage-sqlite for the implementation detail in @capgo/capacitor-data-storage-sqlite, Using @capgo/capacitor-data-storage-sqlite for the native capability in Using @capgo/capacitor-data-storage-sqlite, and @capgo/capacitor-file for the implementation detail in @capgo/capacitor-file.

FAQ

Fast SQL plugin FAQ

How do I install the Fast SQL plugin in a Capacitor app?

Run "bun add @capgo/capacitor-fast-sql" (or "npm install @capgo/capacitor-fast-sql"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-fast-sql" in your app code.

Does @capgo/capacitor-fast-sql work with React, Vue and Angular?

Yes. Fast SQL is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-fast-sql support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-fast-sql free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-fast-sql/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Fast SQL without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Fast SQL changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo