Registry / database / kysely-expo

kysely-expo

JSON →
library56.0.0jsnpmunverified

Expo SQLite dialect and provider for Kysely, the TypeScript SQL query builder. Current stable version is 56.0.0, compatible with Expo SDK 56+. Provides a KyselyProvider React context to initialize and expose the database, with automatic STRICT table creation, type converters (auto affinity and column-name-based), and blob support. Key differentiator: simplifies Kysely integration with Expo's SQLite module, handling connection lifecycle and type conversions for booleans, dates, JSON, and binary data without raw SQL.

npm install kysely-expo
INSTALL
IMPORT
SIG · KYSELY-EXPO
K
kysely-expo
databasejavascriptv56.0.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.

KyselyProvider
import { KyselyProvider } from 'kysely-expo'
import KyselyProvider from 'kysely-expo'
Named export; default export does not exist.
useKysely
import { useKysely } from 'kysely-expo'
import { useKysely } from 'kysely'
Hook provided by kysely-expo, not by Kysely itself.
SQLiteType
import { SQLiteType } from 'kysely-expo'
import { SQLiteType } from 'expo-sqlite'
Enum defined in kysely-expo for type converter configuration.
ColumnNameBasedConverter
import { ColumnNameBasedConverter } from 'kysely-expo'
import { ColumnNameBasedConverter } from 'kysely'
Type for column-name-based conversion rules.

Complete example of setting up KyselyProvider with Expo SQLite, defining a database schema, and using useKysely hook inside a component.

import { KyselyProvider, useKysely } from 'kysely-expo'; import { Generated, type Kysely } from 'kysely'; interface LogTable { id: Generated<number>; message: string; created_at: Date; } interface Database { logs: LogTable; } function InnerComponent() { const db = useKysely<Database>(); const addLog = async () => { await db.insertInto('logs').values({ message: 'Hello', created_at: new Date() }).execute(); }; return <button onClick={addLog}>Add Log</button>; } export default function App() { return ( <KyselyProvider<Database> database="logs.db" autoAffinityConversion debug onInit={async (db: Kysely<Database>) => { await db.schema.createTable('logs') .addColumn('id', 'integer', col => col.autoIncrement().primaryKey()) .addColumn('message', 'text') .addColumn('created_at', 'text') .execute(); }} > <InnerComponent /> </KyselyProvider> ); }
Debug
Known issues
breakingOnly one converter can be used at a time: specify either autoAffinityConversion OR columnNameBasedConversion, not both.
fix
Remove one converter from KyselyProvider options.
affects: >=56.0.0
gotchaSTRICT mode is enabled by default for all tables; this restricts column types to INT, INTEGER, REAL, TEXT, BLOB, ANY only.
fix
Set disableStrictMode: true in KyselyProvider options to disable STRICT tables.
affects: >=56.0.0
gotchaAuto affinity conversion stores booleans as 'true'/'false' TEXT; cannot distinguish from actual strings.
fix
Ensure string columns never contain 'true' or 'false' or use columnNameBasedConversion instead.
affects: >=56.0.0
deprecatedVersion 56.0.0 is tied to Expo SDK 56; future versions may require different Expo SDK major versions.
fix
Check compatibility with your Expo SDK version before upgrading.
affects: 56.0.0
Errors
Common errors & fixes
Cannot find module 'kysely-expo'
Package not installed or peer dependencies not met.
fix
Run `npm install kysely-expo expo-sqlite kysely react`
Type 'false' is not assignable to type 'true'
Using both autoAffinityConversion and columnNameBasedConversion simultaneously.
fix
Set only one converter: either autoAffinityConversion: true or columnNameBasedConversion: [...], not both.
Invalid type 'string' for column 'id'. STRICT mode only allows: INT, INTEGER, REAL, TEXT, BLOB, ANY
Attempting to use a type alias like 'string' instead of 'text' in schema definition with STRICT mode enabled.
fix
Use SQLite type keywords: 'text', 'integer', 'real', 'blob', 'any' instead of TypeScript type names.
Upgrade
Version history
56.0.0latest on npm
Audit
Dependencies
expo-sqliterequiredProvides the underlying SQLite database API for Expo
kyselyrequiredCore query builder library; this package provides a dialect for it
reactrequiredRequired for KyselyProvider component used in React/Expo apps
Agent activity
4 hits · last 30 days
node
4
Resources
kysely-expo — npm install kysely-expo · libregistry