Skip to main content
On the client-side, you can read data directly from the local SQLite database using standard SQL queries.

Basic Queries

Read data using SQL queries:
// Get all todos
const todos = await db.getAll('SELECT * FROM todos');

// Get a single todo
const todo = await db.get('SELECT * FROM todos WHERE id = ?', [todoId]);

// Watch for changes (reactive query)
const stream = db.watch('SELECT * FROM todos WHERE list_id = ?', [listId]);
for await (const todos of stream) {
  // Update UI when data changes
  console.log(todos);
}

Live Queries / Watch Queries

For reactive UI updates that automatically refresh when data changes, use watch queries. These queries execute whenever dependent tables are modified. See Live Queries / Watch Queries for more details.

ORM Support

PowerSync integrates with popular ORM libraries, which provide type safety and additional tooling. Using an ORM is often preferable to writing raw SQL queries, especially for common operations. See ORM Support to learn which ORMs PowerSync supports and how to get started.

Advanced Topics