Awesome
<div align="center"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/duckdb/duckdb-wasm/main/misc/duckdb_wasm.svg"> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/duckdb/duckdb-wasm/main/misc/duckdb_wasm_light.svg"> <img alt="The DuckDB WASM logo." src="https://raw.githubusercontent.com/duckdb/duckdb-wasm/main/misc/duckdb_wasm.svg" height="80"> </picture> <h1>DuckDB-Wasm</h1> </div> <div align="center"> <a href="https://www.npmjs.com/package/@duckdb/duckdb-wasm/v/latest"> <img src="https://img.shields.io/npm/v/@duckdb/duckdb-wasm?logo=npm" alt="duckdb-wasm package on NPM"> </a> <a href="https://github.com/duckdb/duckdb-wasm/actions"> <img src="https://github.com/duckdb/duckdb-wasm/actions/workflows/main.yml/badge.svg?branch=main" alt="Github Actions Badge"> </a> <a href="https://discord.duckdb.org"> <img src="https://shields.io/discord/909674491309850675" alt="Join Discord" /> </a> <a href="https://github.com/duckdb/duckdb/releases/"> <img src="https://img.shields.io/github/v/release/duckdb/duckdb?color=brightgreen&display_name=tag&logo=duckdb&logoColor=white" alt="Latest DuckDB Release"> </a> <a href="https://www.jsdelivr.com/package/npm/@duckdb/duckdb-wasm"> <img src="https://data.jsdelivr.com/v1/package/npm/@duckdb/duckdb-wasm/badge?style=rounded" alt="jsdeliver stats"> </a> </div> <h1></h1>DuckDB is an in-process SQL OLAP Database Management System.
DuckDB-Wasm brings DuckDB to every browser thanks to WebAssembly.
Duckdb-Wasm speaks Arrow fluently, reads Parquet, CSV and JSON files backed by Filesystem APIs or HTTP requests and has been tested with Chrome, Firefox, Safari and Node.js. Learn more about DuckDB-Wasm from our VLDB publication or the recorded talk.
Try it out at shell.duckdb.org or external third party embedding of DuckDB-Wasm, read the API documentation, check out the web-app examples, and chat with us on Discord.
DuckDB and DuckDB-Wasm
DuckDB-Wasm is currently based on DuckDB v1.1.1.
Relevant differences:
- HTTP stack is different between native and Wasm versions of DuckDB. Most relevant are:
- Requests are always upgraded to HTTPS
- Requests needs server to allow Cross Origin access on a given resource
- File system implementation (eg. S3) is different and this might cause some differences
- Extension install is lazy, meaning that
INSTALL extension_name FROM 'https://repository.endpoint.org';
defer fetching the extension to the firstLOAD extension_name;
instruction.INSTALL x FROM community;
shorthands are also supported. - DuckDB-Wasm builds are optimized for download speed. Core extensions like autocomplete, JSON, Parquet and ICU are usually bundled DuckDB binaries, while in duckdb-wasm they are autoloaded (including fetching them) at runtime. In particular for ICU autoloading do not work corrently in all cases, explicit
LOAD icu;
might be needed to reproduce same behaviour. - DuckDB-Wasm is sandboxed and migth not have the same level of support for out-of-core operations and access to file system
- DuckDB-Wasm default mode is single threaded. Multithreading is at the moment still experimental.
Supported DuckDB features:
- DuckDB databases files are compatible to be read from DuckDB-Wasm.
- Databases files can be made available as simple as:
ATTACH 'https://blobs.duckdb.org/data/test.db'; FROM db.t;
demo - Spatial support via
LOAD spatial
spatial demo - A growing subset of extensions, either core, community or external, are supported for DuckDB-Wasm
- Multithreading work but it's still experimental and by default not enabled
DuckDB-Wasm and DuckDB Extension
DuckDB is extensible and this allows to delegate functionality to extensions.
Core extensions are available at https://extensions.duckdb.org, and community extensions are available at https://community-extensions.duckdb.org.
--- Excplicitly load extensions
LOAD icu;
--- Or have them autoloaded when using relevant functions or settings
DESCRIBE FROM read_parquet('https://blobs.duckdb.org/stations.parquet'); -- (this autoloads JSON)
--- Or register extensions
INSTALL h3 FROM community;
INSTALL sqlite_scanner FROM 'https://extensions.duckdb.org';
INSTALL quack FROM 'https://community-extensions.duckdb.org';
--- And then load them
LOAD h3;
LOAD sqlite_scanner;
LOAD quack;
FROM duckdb_extensions() WHERE loaded;
Will show that h3, icu, parquet, quack and sqlite_scanner have been loaded.
You can try the Shell demo with loading of extensions but this do require about 3.2 MB of compressed Wasm files to be transfered over the network (on first visit, caching might help).
Extension sizes will vary depending, among other things, on provided functionality or toolchain used.
Build from source
git clone https://github.com/duckdb/duckdb-wasm.git
cd duckdb-wasm
git submodule init
git submodule update
make apply_patches
make serve
Repository Structure
Subproject | Description | Language |
---|---|---|
duckdb_wasm | Wasm Library | C++ |
@duckdb/duckdb-wasm | Typescript API | Typescript |
@duckdb/duckdb-wasm-shell | SQL Shell | Rust |
@duckdb/duckdb-wasm-app | GitHub Page | Typescript |
@duckdb/react-duckdb | React Hooks | Typescript |