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

remult-sqlite-s3

v0.1.0

Published

A Remult data provider that syncs SQLite to S3

Downloads

88

Readme

remult-sqlite-s3

A Remult data provider that wraps better-sqlite3 with automatic S3 synchronization.

Installation

npm install remult-sqlite-s3 better-sqlite3

Usage

import { remultApi } from 'remult/remult-express'
import { SqlDatabase } from 'remult'
import { createS3DataProvider } from 'remult-sqlite-s3'
import { Task } from './entities/Task'

export const api = remultApi({
  dataProvider: createS3DataProvider({
    file: './mydb.sqlite',
    s3: {
      bucket: 'my-bucket',
      databaseName: 'my-database',
    },
  }),
  entities: [Task],
})

The databaseName is required and must be unique per database to prevent data conflicts in S3.

S3 Configuration

AWS S3

s3: {
  bucket: 'my-bucket',
  databaseName: 'my-database',
  region: 'us-east-1',  // optional, defaults to us-east-1
  credentials: {        // optional, uses AWS SDK default chain if not provided
    accessKeyId: '...',
    secretAccessKey: '...',
  },
}

Cloudflare R2

s3: {
  bucket: 'my-bucket',
  databaseName: 'my-database',
  endpoint: 'https://<account-id>.r2.cloudflarestorage.com',
  credentials: {
    accessKeyId: process.env.R2_ACCESS_KEY_ID!,
    secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
  },
}

MinIO

s3: {
  bucket: 'my-bucket',
  databaseName: 'my-database',
  endpoint: 'http://localhost:9000',
  forcePathStyle: true,
  credentials: {
    accessKeyId: 'minioadmin',
    secretAccessKey: 'minioadmin',
  },
}

Options

| Option | Description | Required | Default | |--------|-------------|----------|---------| | file | Path to SQLite database file | Yes | - | | s3.bucket | S3 bucket name | Yes | - | | s3.databaseName | Unique name for this database | Yes | - | | s3.keyPrefix | Prefix for S3 keys (for organization) | No | - | | s3.region | AWS region | No | us-east-1 | | s3.endpoint | Custom endpoint for S3-compatible storage | No | - | | s3.forcePathStyle | Use path-style URLs (required for MinIO) | No | false | | s3.credentials | AWS credentials | No | SDK default | | sync.mode | async (fast) or sync (durable) | No | async | | sync.snapshotInterval | Interval between snapshots (ms) | No | 300000 | | sync.lockTtl | Lock TTL (ms) | No | 60000 | | sync.forceLock | Force acquire lock (dev only) | No | false | | verbose | Enable verbose logging | No | false |

How It Works

  1. On startup: Acquires a distributed lock, downloads the latest snapshot from S3 if local database is missing
  2. On writes: Syncs changes to S3 (immediately in sync mode, periodically in async mode)
  3. On shutdown: Takes a final snapshot and releases the lock

S3 Structure

[keyPrefix/]<databaseName>/
├── lock.json
└── generations/<id>/
    ├── snapshot.db
    └── snapshot.meta.json

Framework Examples

SvelteKit

See the examples/sveltekit folder for a complete working example.

// src/server/api.ts
import { remultApi } from 'remult/remult-sveltekit'
import { createS3DataProvider } from 'remult-sqlite-s3'
import { building } from '$app/environment'
import { env } from '$env/dynamic/private'

export const api = remultApi({
  dataProvider: building ? undefined : createS3DataProvider({
    file: './mydb.sqlite',
    s3: {
      bucket: env.S3_BUCKET!,
      databaseName: env.DATABASE_NAME!,
    },
  }),
  entities: [...],
})

Limitations

  • Single writer: Only one instance can write at a time (by design)
  • Cold starts: Initial recovery from S3 adds startup latency
  • Best for: Low-to-medium write loads in serverless environments

License

MIT