---
title: "WebAssembly functions for your SQLite-compatible database"
description: "libSQL, Turso's open-contribution fork of SQLite, adds user-defined functions written in WebAssembly and registered directly from SQL with a CREATE FUNCTION ..."
url: "https://swe.quest/articles/webassembly-functions-for-your-sqlite-compatible-database-e23432782d9473c3"
canonical: "https://turso.tech/blog/webassembly-functions-for-your-sqlite-compatible-database-7e1ad95a2aa7"
source: "Turso"
published: "2022-11-23"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["sqlite","webassembly","rust","databases"]
---

# WebAssembly functions for your SQLite-compatible database

A post on [Turso](https://swe.quest/sources/turso.md), published 2022-11-23, 6 min read, How-to. Original: [https://turso.tech/blog/webassembly-functions-for-your-sqlite-compatible-database-7e1ad95a2aa7](https://turso.tech/blog/webassembly-functions-for-your-sqlite-compatible-database-7e1ad95a2aa7)

## Summary

libSQL, Turso's open-contribution fork of SQLite, adds user-defined functions written in WebAssembly and registered directly from SQL with a CREATE FUNCTION ... LANGUAGE wasm statement, instead of only through SQLite's C API. WebAssembly was chosen for its sandboxing, portability, performance and wide use as a compile target from languages such as Rust and Zig. A walkthrough compiles Rust encrypt/decrypt functions with the libsql\_bindgen crate or its playground and loads them as binary blobs in the libSQL shell. Functions cannot touch system resources such as time, randomness or the network, and their signatures must map to INTEGER, REAL, TEXT and BLOB types.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- SQLite basics ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))
- SQL functions ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- WebAssembly basics ([easy posts on WebAssembly](https://swe.quest/tags/webassembly.md?difficulty=easy))

## Keywords

libSQL, SQLite, WebAssembly, libsql\_bindgen, CREATE FUNCTION, Wasmtime

## Related posts

- [How We Built the Turso Shell in the Browser](https://swe.quest/articles/how-we-built-the-turso-shell-in-the-browser-3b4c7642ce66be0b.md): Turso · 2025-10-14 · Medium · 9 min read · WebAssembly, SQLite, React, Frontend, Browsers
  Turso's SQLite-compatible database can run entirely in the browser via WebAssembly, persisting data to OPFS with no backend.
- [Introducing Turso in the Browser](https://swe.quest/articles/introducing-turso-in-the-browser-111a711a5e4d489d.md): Turso · 2025-10-08 · Medium · 3 min read · SQLite, WebAssembly, Browsers, Local-first & sync, JavaScript
  Turso, a from-scratch SQLite rewrite, now runs in the browser via WebAssembly as the npm package @tursodatabase/database-wasm, with a better-sqlite3-like API whose methods are all async because of OPFS.
- [Introducing Limbo: A complete rewrite of SQLite in Rust](https://swe.quest/articles/introducing-limbo-a-complete-rewrite-of-sqlite-in-rust-eb77d828af295b26.md): Turso · 2024-12-10 · Easy · 7 min read · SQLite, Rust, Formal methods, Testing, WebAssembly
  Limbo is Turso's from-scratch rewrite of SQLite in Rust that aims for full language and file-format compatibility, memory safety and a modern architecture.
- [Introducing Fast, Native Encryption in Turso Database](https://swe.quest/articles/introducing-fast-native-encryption-in-turso-database-3bdde23a22f614e0.md): Turso · 2025-10-07 · Medium · 4 min read · SQLite, Cryptography, Storage engines, Rust, Performance engineering
  Turso Database, a Rust rewrite of SQLite, now supports native encryption at rest using AEAD ciphers (AEGIS-256 and AES-GCM).
- [Postgres Foreign Data Wrappers with Wasm](https://swe.quest/articles/postgres-foreign-data-wrappers-with-wasm-121e854eab291417.md): Supabase · 2024-08-16 · Medium · 5 min read · PostgreSQL, WebAssembly, Rust, Sandboxing & isolation
  Supabase Wrappers, a Rust framework for building Postgres Foreign Data Wrappers, now supports WebAssembly FDWs that are downloaded from URLs like GitHub or S3, checksum-verified, cached and run in a sandboxed Wasm runtime inside the Postgres extension.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
