Registry / database / kysely-expo-sqlite-dialect

kysely-expo-sqlite-dialect

JSON →
library0.3.0jsnpmunverified

A Kysely dialect for Expo SQLite that bridges the Kysely query builder with SQLite databases in React Native/Expo applications. Current stable version is 0.3.0. This dialect supports modern Expo SDK and provides type-safe SQL query building, pragmatic defaults for performance (WAL mode, synchronous, foreign keys), and features like change listeners and connection callbacks. It requires peer dependencies expo-sqlite >=13.0.0, kysely >=0.28.0, expo-modules-core, and react-native-web >=0.19.0. Key differentiator: integrates Kysely's type-safe SQL builder into Expo's SQLite API, enabling compile-time query validation with full TypeScript support.

npm install kysely-expo-sqlite-dialect
INSTALL
IMPORT
SIG · KYSELY-EXPO-SQLITE
K
kysely-expo-sqlite-dialect
databasejavascriptv0.3.0
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.

ExpoSQLiteDialect
✓ import { ExpoSQLiteDialect } from 'kysely-expo-sqlite-dialect'
✗ import ExpoSQLiteDialect from 'kysely-expo-sqlite-dialect'
This is a named export, not a default export. Incorrect default import will cause TypeScript/JavaScript errors.
Kysely
✓ import { Kysely } from 'kysely'
✗ import Kysely from 'kysely'
Kysely is a named export from the kysely package. Common mistake: using default import which is not provided.
Database
✓ interface Database { ... } // No import needed; user-defined type
✗ import { Database } from 'kysely'
The Database type is user-defined and not exported by kysely or this dialect. Do not import it.

Creates a Kysely instance with Expo SQLite dialect and demonstrates a basic query to fetch all users.

import { Kysely } from 'kysely'; import { ExpoSQLiteDialect } from 'kysely-expo-sqlite-dialect'; interface Database { users: { id: number; name: string; email: string; created_at: Date }; posts: { id: number; user_id: number; title: string; content: string; created_at: Date }; } const db = new Kysely<Database>({ dialect: new ExpoSQLiteDialect({ database: 'myapp.db', debug: __DEV__, pragmas: { journal_mode: 'WAL', synchronous: 'NORMAL', foreign_keys: 1, cache_size: -2000, temp_store: 'MEMORY', }, onCreateConnection: async (db) => { await db.execAsync('CREATE EXTENSION IF NOT EXISTS ...'); }, }), }); async function getAllUsers() { return await db.selectFrom('users').selectAll().execute(); }
Debug
Known issues
breakingWAL mode is not supported in wa-sqlite (web platform). If you enable WAL mode, the app will crash on web.
fix
Set journal_mode to 'DELETE' or conditionally set it only on iOS/Android using Platform.OS.
affects: >=0.1.0
breakingexpo-sqlite version compatibility: The dialect requires expo-sqlite >=13.0.0. Using older versions may cause runtime errors.
fix
Ensure expo-sqlite is version 13.0.0 or later in your package.json.
affects: >=0.3.0
breakingkysely version compatibility: The dialect requires kysely >=0.28.0. Older versions may lack required APIs.
fix
Update kysely to version 0.28.0 or later.
affects: >=0.3.0
gotchaThe dialect uses named export ('ExpoSQLiteDialect'), not default export. Using default import will cause a runtime error.
fix
Use import { ExpoSQLiteDialect } from 'kysely-expo-sqlite-dialect'.
affects: >=0.1.0
gotchaThe 'enableChangeListener' option may have performance implications on large datasets. Not recommended for production without testing.
fix
Use with caution; only enable if you need reactive queries.
affects: >=0.1.0
deprecatedThe 'finalizeUnusedStatementsBeforeClosing' option is experimental and its behavior may change in future versions.
fix
Monitor changelog for updates; avoid relying on it in critical code.
affects: >=0.3.0
Errors
Common errors & fixes
Cannot find module 'kysely-expo-sqlite-dialect' or its corresponding type declarations
Package not installed or not properly resolved.
fix
Run: npm install kysely-expo-sqlite-dialect kysely expo-sqlite
TypeError: Cannot read properties of undefined (reading 'then')
Attempting to use a Kysely instance without initializing the dialect correctly, or missing peer dependencies.
fix
Ensure all peer dependencies are installed: expo-sqlite, kysely, and expo-modules-core. Then verify dialect options are passed correctly.
Error: SQLite3 at step: (node:*) Error: no such table: users
Table does not exist; the user forgot to run schema creation before queries.
fix
Execute CREATE TABLE statements via db.schema.createTable(...).execute() before running queries.
Type error: Property 'default' does not exist on type 'typeof import("kysely-expo-sqlite-dialect")'
Using default import instead of named import.
fix
Change to: import { ExpoSQLiteDialect } from 'kysely-expo-sqlite-dialect'
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
kyselyrequiredThe core Kysely library is a peer dependency required to use the dialect.
expo-sqliterequiredExpo SQLite module is required for database interaction in the Expo environment.
react-native-weboptionalRequired for web platform support; peer dependency.
Agent activity
10 hits · last 30 days
node
8
Resources
kysely-expo-sqlite-dialect — npm install kysely-expo-sqlite-dialect · libregistry