Skip to main content

usePowerSyncKysely()

function usePowerSyncKysely<T>(): PowerSyncKyselyDatabase<T>

Provides a Kysely-wrapped PowerSync database for type-safe database queries.

This composable wraps the PowerSync database instance with Kysely's type-safe query builder, allowing you to write type-safe SQL queries with full TypeScript support.

Type Parameters

Type ParameterDescription
TYour database type (from your schema)

Returns

PowerSyncKyselyDatabase<T>

Kysely database instance (not { db })

Example

import { usePowerSyncKysely } from '@powersync/nuxt'
import { type Database } from '../powersync/AppSchema'

// Returns db directly, not { db }
const db = usePowerSyncKysely<Database>()

// Use Kysely query builder
const users = await db.selectFrom('users').selectAll().execute()