SQLite Cloud

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

Define custom functions
Scalar, aggregate, window, collation sequences with JavaScript
Run JavaScript inside your SQL
No extra setup required
Sync function definitions across devices
Using SQLite-Sync
Write once, run anywhere with JavaScript
Share the same logic across platforms, languages, and frameworks using JavaScript
Cross-platform & offline-ready
Works on iOS, Android, macOS, Windows, and Linux
Perfect for distributed and edge-native apps
Run close to users with zero latency and full autonomy

<Sample Code>

Go to GitHub Repo

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
Subscribe to our newsletter
The latest news, articles, and resources, sent to your inbox.

© 2025 SQLite Cloud, Inc. All rights reserved.