Skip to content

Getting Started

Connect SQLite is a SQLite session store for Sails.js applications. It uses better-sqlite3 for fast, synchronous database operations.

Installation

bash
npm install @sailscastshq/connect-sqlite

Basic Setup

Configure your session store in config/session.js:

javascript
module.exports.session = {
  secret: process.env.SESSION_SECRET,
  adapter: '@sailscastshq/connect-sqlite',
  url: 'sqlite:./db/sessions.db',

  cookie: {
    secure: true,
    maxAge: 24 * 60 * 60 * 1000 // 24 hours
  }
}

That's it! Sails will automatically use SQLite to store sessions.

URL Formats

Connect SQLite supports multiple URL formats:

javascript
// File-based database (recommended for production)
url: 'sqlite:./db/sessions.db'

// Absolute path
url: 'sqlite:/var/data/sessions.db'

// In-memory database (for testing)
url: 'sqlite::memory:'

Why SQLite for Sessions?

  • No external dependencies - No Redis or Memcached server to manage
  • Persistent storage - Sessions survive server restarts
  • Low memory footprint - Perfect for single-instance deployments
  • Fast - better-sqlite3 is one of the fastest SQLite bindings for Node.js

Next Steps

All open source projects are released under the MIT License.