Registry / storage / express-sqlite

express-sqlite

JSON →
library0.1.6jsnpmunverified

SQLite-backed session store for Express.js using better-sqlite3. Version 0.1.6 provides a drop-in replacement for express-session stores with TypeScript support, automatic table creation, and optional WAL mode for better concurrency. Compared to other session stores, it uses synchronous better-sqlite3 API for simplicity and zero dependencies beyond better-sqlite3 and express-session. Ideal for small-to-medium Node.js apps that want session persistence without a full database server.

npm install express-sqlite
INSTALL
IMPORT
SIG · EXPRESS-SQLITE
E
express-sqlite
storagejavascriptv0.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SQLiteStore
import { SQLiteStore } from 'express-sqlite'
import SQLiteStore from 'express-sqlite'
Default export not provided; named import only.
StoreOptions
import { StoreOptions } from 'express-sqlite'
TypeScript type, also importable via type import.
StoreDatabase
import { StoreDatabase } from 'express-sqlite'
TypeScript type for the database argument (string | Buffer | BetterSqlite3.Database).

Basic Express app with SQLite session store, tracking page views per session.

import express from 'express'; import session from 'express-session'; import { SQLiteStore } from 'express-sqlite'; const app = express(); const store = new SQLiteStore('sessions.db'); app.use(session({ store, secret: 'your-secret-key', resave: false, saveUninitialized: false, cookie: { secure: false } // set true in production with HTTPS })); app.get('/', (req, res) => { if (req.session.views) { req.session.views++; res.send(`Visited ${req.session.views} times`); } else { req.session.views = 1; res.send('Welcome!'); } }); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
gotchaThe database file and its parent directory must be writable; the library may create directories if they do not exist.
fix
Ensure the path is writable or create directories manually.
affects: >=0.0.0
gotchabetter-sqlite3 is a synchronous library, so database operations block the event loop. Not suitable for high-concurrency production scenarios.
fix
Consider using an asynchronous session store (e.g., connect-redis or connect-session-knex) for high-load apps.
affects: >=0.0.0
gotchaWAL mode is enabled by default; disabling it may cause performance issues under concurrent access.
fix
Keep WAL enabled unless you have a specific reason to disable it.
affects: >=0.0.0
deprecatedThe default table name is 'Sessions' with capital 'S' – this may cause issues on case-sensitive filesystems.
fix
Explicitly set tableName to lowercase 'sessions' for cross-platform consistency.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'better-sqlite3'
Missing peer dependency better-sqlite3.
fix
npm install better-sqlite3
Error: The 'database' argument must be a string, Buffer, or BetterSqlite3.Database instance
Passed an invalid type (e.g., number or object) to SQLiteStore constructor.
fix
Ensure first argument is a file path (string), Buffer, or an existing better-sqlite3 Database instance.
TypeError: Class extends value undefined is not a constructor or null
express-session is missing or its Store class is not imported correctly.
fix
Install express-session and import it before using SQLiteStore.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
express-sessionrequiredPeer dependency; the store extends express-session's Store class
better-sqlite3requiredSynchronous SQLite3 driver used for database operations
Agent activity
28 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
express-sqlite — npm install express-sqlite · libregistry