npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tanstack/capacitor-db-sqlite-persistence

v0.1.5

Published

Capacitor SQLite persisted collection adapter for TanStack DB

Readme

@tanstack/capacitor-db-sqlite-persistence

Thin SQLite persistence for Capacitor apps using @capacitor-community/sqlite.

Public API

  • createCapacitorSQLitePersistence(...)
  • persistedCollectionOptions(...) (re-exported from core)

Install

pnpm add @tanstack/capacitor-db-sqlite-persistence @capacitor-community/sqlite

Quick start

import { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite'
import { createCollection } from '@tanstack/db'
import { QueryClient } from '@tanstack/query-core'
import { queryCollectionOptions } from '@tanstack/query-db-collection'
import {
  createCapacitorSQLitePersistence,
  persistedCollectionOptions,
} from '@tanstack/capacitor-db-sqlite-persistence'

type Todo = {
  id: string
  title: string
  completed: boolean
}

const sqlite = new SQLiteConnection(CapacitorSQLite)
const database = await sqlite.createConnection(
  `tanstack-db`,
  false,
  `no-encryption`,
  1,
  false,
)

await database.open()

// One shared persistence instance for the whole database.
const persistence = createCapacitorSQLitePersistence({
  database,
})
const queryClient = new QueryClient()

export const todosCollection = createCollection(
  persistedCollectionOptions<Todo, string>({
    ...queryCollectionOptions({
      queryKey: [`todos`],
      queryFn: async () => {
        const response = await fetch(`/api/todos`)
        return response.json() as Promise<Array<Todo>>
      },
      queryClient,
      getKey: (todo) => todo.id,
    }),
    id: `todos`,
    persistence,
    schemaVersion: 1, // Per-collection schema version
  }),
)

Platform notes

  • createCapacitorSQLitePersistence is shared across collections.
  • Mode defaults (sync-present vs sync-absent) are inferred from whether a sync config is present in persistedCollectionOptions.
  • This package assumes you provide an already-created and opened SQLiteDBConnection.
  • Calling close() on this driver's database adapter closes the underlying SQLiteDBConnection, so treat driver ownership as connection ownership.
  • This package targets native Capacitor runtimes. Use the dedicated browser and Electron persistence packages instead of the plugin's web or Electron modes.
  • The plugin's database version and upgrade APIs are separate from TanStack DB schemaVersion.
  • @capacitor-community/sqlite uses SQLCipher-backed native builds, so app setup may require additional platform configuration outside this package.
  • Capacitor 8 creates iOS projects with Swift Package Manager by default, but @capacitor-community/sqlite currently links through CocoaPods on iOS. Add iOS with npx cap add ios --packagemanager CocoaPods, or recreate an SPM project in CocoaPods mode before expecting the native plugin to load.

Testing

  • pnpm --filter @tanstack/capacitor-db-sqlite-persistence test:e2e runs the package e2e suite against the default better-sqlite3 harness.
  • pnpm --filter @tanstack/capacitor-db-sqlite-persistence test:e2e:ios builds the package-local Capacitor harness in e2e/app, launches the iOS simulator, and runs the full persisted collection e2e suite inside the real native Capacitor runtime.
  • pnpm --filter @tanstack/capacitor-db-sqlite-persistence test:e2e:android builds the same package-local Capacitor harness in e2e/app, launches an Android emulator or uses a connected debug target, and runs the full persisted collection e2e suite inside the real native Capacitor runtime.
  • test:e2e:ios is a repo-local validation path for this package. It depends on the checked-in e2e/app harness plus local Capacitor/Xcode tooling.
  • test:e2e:android depends on a local Android SDK. The runner auto-detects the default macOS SDK location, boots the first available AVD when needed, and reads the app-owned SQLite result database out of the debug sandbox with adb run-as.
  • The native harness lives under e2e/app so the same app can be extended to other native targets later, including Android.