limbo/bindings/javascript/packages/wasm
Pekka Enberg a0bd11c035
Merge 'No tempfiles on wasm' from Nikita Sivukhin
We now can attempt to create temp file in WASM for sorter and hash join
which will result in crash:
```
stderr | promise.test.ts > sorter-wasm
thread '<unnamed>' panicked at library/std/src/sys/pal/wasi/os.rs:125:5:
stderr | promise.test.ts > sorter-wasm
no filesystem on wasm
stderr | promise.test.ts > sorter-wasm
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
This PR make simple adjustment to always use in-memory IO for temp files
in WASM

Closes #4256
2025-12-17 12:23:09 +02:00
..
index-bundle.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
index-default.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
index-turbopack-hack.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
index-vite-dev-hack.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
package.json Turso 0.4.0-pre.17 2025-12-17 10:18:19 +02:00
promise-bundle.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
promise-default.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
promise-turbopack-hack.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
promise-vite-dev-hack.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
promise.test.ts add test with huge hash join 2025-12-17 12:18:16 +04:00
README.md Beta 2025-10-01 07:18:25 +03:00
tsconfig.json javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
vite javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
vite.config.js javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
vitest.config.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
wasm-inline.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00
worker.ts javascript: Rename "browser" packages to "wasm" 2025-09-29 17:02:34 +03:00

Turso Database for JavaScript in Browser

npm

Chat with other users of Turso on Discord


About

This package is the Turso embedded database library for JavaScript in Browser.

⚠️ Warning: This software is in BETA. It may still contain bugs and unexpected behavior. Use caution with production data and ensure you have backups.

Features

  • SQLite compatible: SQLite query language and file format support (status).
  • In-process: No network overhead, runs directly in your Node.js process
  • TypeScript support: Full TypeScript definitions included

Installation

npm install @tursodatabase/database-wasm

Getting Started

In-Memory Database

import { connect } from '@tursodatabase/database-wasm';

// Create an in-memory database
const db = await connect(':memory:');

// Create a table
await db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');

// Insert data
const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
await insert.run('Alice', 'alice@example.com');
await insert.run('Bob', 'bob@example.com');

// Query data
const users = await db.prepare('SELECT * FROM users').all();
console.log(users);
// Output: [
//   { id: 1, name: 'Alice', email: 'alice@example.com' },
//   { id: 2, name: 'Bob', email: 'bob@example.com' }
// ]

File-Based Database

import { connect } from '@tursodatabase/database-wasm';

// Create or open a database file
const db = await connect('my-database.db');

// Create a table
await db.exec(`
  CREATE TABLE IF NOT EXISTS posts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    content TEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  )
`);

// Insert a post
const insertPost = db.prepare('INSERT INTO posts (title, content) VALUES (?, ?)');
const result = await insertPost.run('Hello World', 'This is my first blog post!');

console.log(`Inserted post with ID: ${result.lastInsertRowid}`);

Transactions

import { connect } from '@tursodatabase/database-wasm';

const db = await connect('transactions.db');

// Using transactions for atomic operations
const transaction = db.transaction(async (users) => {
  const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
  for (const user of users) {
    await insert.run(user.name, user.email);
  }
});

// Execute transaction
await transaction([
  { name: 'Alice', email: 'alice@example.com' },
  { name: 'Bob', email: 'bob@example.com' }
]);

API Reference

For complete API documentation, see JavaScript API Reference.

License

This project is licensed under the MIT license.

Support