Skip to content

Here’s the polished version of the sqlite3 setup:

SQLite3 Setup ​

This version of SQLite3 works well even on platforms like StackBlitz.

Step 1: Install SQLite3 ​

Run the following command to install the sqlite3 package:

sh
npm i sqlite3

Step 2: Configure the dataProvider ​

In your api.ts or server file, configure the dataProvider to connect to the SQLite database using sqlite3:

ts
import express from 'express'
import { remultExpress } from 'remult/remult-express'
import { SqlDatabase } from 'remult'
import sqlite3 from 'sqlite3'
import { Sqlite3DataProvider } from 'remult/remult-sqlite3'

const app = express()

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

This configuration connects to an SQLite database stored in the mydb.sqlite file. The Sqlite3DataProvider is wrapped inside the SqlDatabase class, enabling Remult to work with SQLite databases smoothly across different environments, including StackBlitz.

MIT Licensed | Made by the Remult team with ❀️