duckdbExample
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
main.tsx
https://taras--3e777884278411f0b46e569c3dd06744.web.val.run
DuckDB works on Val Town, with only one small tweak! We're basically using DuckDB in the same way you'd use it with a browser - using the WASM package with its dependencies fetched from jsdelivr.
The only trick is to create the worker ourselves rather than using duckdb.createWorker. DuckDB's built-in createWorker method doesn't specify a worker type, which causes type to default to classic, and Deno (our runtime) doesn't support classic workers.
Note: A small check was added to make this compatible with local Deno.
if (typeof Deno !== "undefined") {
return new Worker(url, { type: "module", deno: true });
}