JavaScript
Extend your SQLite database with custom JavaScript functions
SQLite-JS
SQLite-JS is a powerful extension that lets you write custom cross-platform logic directly in your SQLite database using JavaScript. With support for scalar, aggregate, window functions, and collation sequences, you can express complex operations with ease, all using familiar SQL syntax.
Server-side logic automatically in sync
By integrating SQLite-JS with SQLite-Sync, your user-defined JavaScript functions are automatically synchronized across all clients connected to your cluster, keeping logic consistent everywhere, even offline, for a truly consistent offline-first server-side logic distribution.
Key Features
<Sample Code>
Use JavaScript in SQL and keep logic consistent
Functions sync across clients — no redeploys needed.
-- Define a JavaScript function to extract domain from an email
SELECT js_create_scalar('get_domain', '(function(args) {
const email = args[0];
return email.split("@")[1] || null;
})');
-- Use it in your query
SELECT email, get_domain(email) AS domain FROM users;
-- Initialize the sync table (one-time setup)
SELECT js_init_table(1); -- Load and activate synced functions