Skip to content

Bun:SQLite

Step 1: Configure the dataProvider

In your api.ts or server file, configure the dataProvider to use bun:sqlite as follows:

ts
import express from 'express'
import { remultExpress } from 'remult/remult-express'
import { SqlDatabase } from 'remult'
import { Database } from 'bun:sqlite'
import { BunSqliteDataProvider } from 'remult/remult-bun-sqlite'

const app = express()

app.use(
  remultExpress({
    dataProvider: new SqlDatabase(
      new BunSqliteDataProvider(new Database('./mydb.sqlite')),
    ),
  }),
)

Explanation:

  • bun:sqlite: This uses Bun's native SQLite database, bun:sqlite, to manage SQLite databases efficiently in a Bun-based environment.
  • BunSqliteDataProvider: The BunSqliteDataProvider integrates the Bun SQLite database as a data provider for Remult.
  • SqlDatabase: Wraps the BunSqliteDataProvider to make it compatible with Remult's SQL-based data provider system.

This setup allows you to use Bun's SQLite implementation as the database provider for your Remult application, leveraging Bun’s performance benefits with SQLite.

MIT Licensed | Made by the Remult team with ❤️