The fastest way to
build real-time features
SKDB is an embedded SQL database that stays in sync.
Built from the ground up and open source, it runs in the browser or the backend.
Work Locally
SKDB lets you work locally. Mirror the tables and views you need and they will always reflect the latest data.
await skdb.mirror(
{
table: "chess_moves",
filterExpr: "game_state = 'started'"
}
);
React to updates in real-time
Mirror Mode
Mirrored tables update instantly as other users manipulate rows.
Subscriptions
Subscribe to SQL queries to be notified when things change. Get either the whole result set each time or just the deltas.
Instant
This powerful combination lets you build live experiences. As things change, you can reflect this to your users instantly and effortlessly.
await skdb.watch(
`SELECT
move_num, player, piece, position
FROM chess_moves
WHERE game_id = @game`,
{ game: 83723 },
moves => render_game(moves),
);
SKDB is very efficient thanks to a purpose-built engine. Queries are not re-run continuously but are incrementally maintained, so you can scale to as many watched queries as you need.
Insert, update, or delete to communicate
Mirroring works both ways. Your local changes are immediately shared with other users.
Real-time communication and collaboration is now as simple as updating your tables, your shared state.
await skdb.exec(
`INSERT INTO chess_moves (
game_id, player, move_num, piece, position, skdb_access
) VALUES (
@game, @player, @move, @piece, @position, 'read-only'
)`,
{
game: 83723,
player: 32412,
move: 8,
piece: 'N1',
position: 'f3',
},
);
If you're offline, any local changes are synchronized when you come back online. Reconnects are automatic and fast, transmitting only what has changed.
Query with SQL
SKDB lets you work with SQL. Access and manipulate your application state using the power and convenience of a declarative query language.
SKDB uses plain simple SQL: there's nothing extra to learn or do to make it work.
Aggregate with GROUP BY, join tables, create indexes, use transactions – everything you expect of a SQL engine.
await skdb.exec(
`SELECT piece, COUNT(*) AS n_moves
FROM chess_moves
WHERE player = @player
GROUP BY piece
ORDER BY n_moves DESC`,
{ player: 32412 },
);
Control data sharing
Privacy Controls
Fine-grained privacy controls are built in. Control who can see data and who can modify it. Data that a user cannot see is never mirrored locally and so never shows up in their query results.
Automatic Updates
As privacy rules change SKDB automatically takes care of adding and removing data from local tables.
Conflict resolution
Concurrent data modification is of course supported. You can opt for a simple resolution policy when you don't care, or take full control when you do.
Develop quickly and easily
SKDB provides a server you can run locally for offline development. It supports convenient features to make dev iteration fast, such as instant test user creation and data auto-migration as you iterate on your schema.
React is commonly used with SKDB. An integration via the skdb-react package is provided along with components for debugging and testing.