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

@eduh_dev021/wappmeow-store-sqlite

v0.1.2

Published

SQLite store provider for wappmeow

Readme

@eduh_dev021/wappmeow-store-sqlite

SQLite-backed persistent store for @eduh_dev021/wappmeow. Suitable for single-process bots, dev sessions, and small-to-medium production deployments that don't need a network database.

Backed by better-sqlite3 on Node, bun:sqlite on Bun, or the runtime's built-in node:sqlite when no native addon is available (auto-detected). Lazy migrations run on first touch per domain; all writes go through withTransaction so partial failures roll back cleanly.

Install

npm install @eduh_dev021/wappmeow-store-sqlite better-sqlite3
# or on Bun
bun add @eduh_dev021/wappmeow-store-sqlite
# or with no native dependency at all (Node 22.13+)
npm install @eduh_dev021/wappmeow-store-sqlite

better-sqlite3 is an optional peer dependency. Skip it and the store falls back to node:sqlite, which ships with the runtime, so nothing has to be compiled.

Choosing a driver

'auto' (the default) picks bun:sqlite under Bun, otherwise better-sqlite3, falling back to node:sqlite when the addon is not installed. Pin driver explicitly only when you need a specific backend.

| Driver | Requires | Notes | | ---------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | better-sqlite3 | native addon (build/prebuild) | Fastest row materialization on Node. Does not load under Bun. | | bun | Bun | bun:sqlite, ships with the runtime. | | node | Node 22.13+ or Bun 1.4+ | node:sqlite, ships with the runtime. Node 22.5 to 22.12 keeps it behind --experimental-sqlite; Node warns while the module is marked experimental. |

On Node 20, 21, or 22.5 to 22.12 without the flag, node:sqlite does not exist, so 'auto' cannot fall back to it - you get the better-sqlite3 install error, which is the only real fix there. Installing the addon keeps working on every version: 'auto' prefers it and never touches node:sqlite.

The database file is identical across drivers - the same schema and migrations - so you can switch drivers on an existing store without migrating anything.

Write throughput is effectively the same on all three (SQLite itself dominates). node:sqlite is slower only when materializing wide or multi-row result sets, since it builds a fresh object per row: roughly 1.3x on a single wide row and 2.5x on a 50-row page with blobs, measured against better-sqlite3 on Node 22. That cost lands on history/mailbox queries, not on the per-message session writes.

Quick start

import { createStore, WaClient } from '@eduh_dev021/wappmeow'
import { createSqliteStore } from '@eduh_dev021/wappmeow-store-sqlite'

const store = createStore({
    backends: {
        sqlite: createSqliteStore({ path: '.auth/state.sqlite' })
    },
    providers: {
        auth: 'sqlite',
        signal: 'sqlite',
        senderKey: 'sqlite',
        appState: 'sqlite',
        // optional: archive messages/threads/contacts for later quote/addon decryption
        messages: 'sqlite',
        threads: 'sqlite',
        contacts: 'sqlite',
        privacyToken: 'sqlite'
    }
})

const client = new WaClient({ store, sessionId: 'default' })

Config

createSqliteStore(config) accepts:

| Field | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | | path | Database file path. Use ':memory:' for an ephemeral DB. Mutually exclusive with connection. | | connection | Pre-opened WaSqliteConnection to reuse instead of opening a new one. Caller owns the lifecycle (per-store destroy() does not close it). | | driver | 'auto' (default) / 'better-sqlite3' / 'bun' / 'node'. Ignored when connection is set. | | pragmas | Extra PRAGMA statements merged on top of defaults. Ignored when connection is set. | | tableNames | Per-domain table name overrides. Ignored when connection is set. | | batchSizes | Per-domain bulk-read batch sizes. | | cacheTtlMs | TTLs for the cache domains (retry, groupMetadata, deviceList, messageSecret). |

The returned object is shaped as a WaStoreBackend ({ stores, caches }) - feed it to createStore({ backends: { sqlite: ... } }) and reference it by name in providers/cacheProviders.

Bring your own connection

To share a single SQLite connection with the rest of your application, open it yourself with openSqliteConnection and pass it through connection:

import { createSqliteStore, openSqliteConnection } from '@eduh_dev021/wappmeow-store-sqlite'

const connection = await openSqliteConnection({
    path: 'app.sqlite',
    sessionId: 'shared',
    pragmas: { journal_mode: 'WAL', synchronous: 'NORMAL' }
})

const store = createStore({
    backends: { sqlite: createSqliteStore({ connection }) },
    providers: { auth: 'sqlite', signal: 'sqlite', senderKey: 'sqlite', appState: 'sqlite' }
})

// ... use connection elsewhere in your app ...

await store.destroy()
connection.close() // you opened it, you close it

Notes

  • Migrations are idempotent and run lazily. Sharing one DB file across many session ids is supported and recommended (each session is scoped by session_id).
  • For high write throughput, set pragmas: { journal_mode: 'WAL', synchronous: 'NORMAL' }.
  • The cache domains (retry, groupMetadata, deviceList, messageSecret) expire rows lazily on read; you don't need a background cleanup job.

See the main @eduh_dev021/wappmeow docs for the full store contract and per-domain semantics.