Build and ship JS apps.
Add C++ and Rust as needed.
Free and open source under the MIT license.
# For library projects
npx crossbind build
# For app projects
npx crossbind app publish app-store
- BrowsersChrome, Firefox, Safari
- MobileiOS, Android
crossbind apps · React Native - Server & EdgeNode.js, Cloudflare Workers
- DesktopmacOS, Linux, Windows
crossbind apps · Electron - WASIwasmtime 47+
From native source to every runtime.
crossbind takes C++ and Rust from wherever they live, builds them for every target and hands each platform what it loads, packaged for npm.
Use SQLite from JavaScript.
Run SQL queries against crossbind's library catalog. SQLite runs as WebAssembly in your browser.
#pragma once
#include <sqlite3.h>
#include <stdexcept>
#include <string>
class Database {
public:
Database() {
if (sqlite3_open(":memory:", &handle) != SQLITE_OK) throw std::runtime_error("cannot open the database");
}
~Database() { sqlite3_close(handle); }
std::string version() { return sqlite3_libversion(); }
void exec(const std::string& sql) { run(sql); }
std::string query(const std::string& sql) {
rows = "[";
run(sql);
rows += "]";
return rows;
}
private:
void run(const std::string& sql) {
char* message = nullptr;
if (sqlite3_exec(handle, sql.c_str(), collect, this, &message) == SQLITE_OK) return;
const std::string reason = message ? message : "unknown error";
sqlite3_free(message);
throw std::runtime_error(reason);
}
static int collect(void* owner, int count, char** values, char** names) {
Database* self = static_cast<Database*>(owner);
if (self->rows.size() > 1) self->rows += ",";
self->rows += "{";
for (int column = 0; column < count; column += 1) {
if (column) self->rows += ",";
self->rows += quote(names[column]) + ":" + (values[column] ? quote(values[column]) : "null");
}
self->rows += "}";
return 0;
}
static std::string quote(const char* text) {
std::string out = "\"";
for (const char* character = text; *character; character += 1) {
if (*character == '"' || *character == '\\') out += '\\';
out += *character;
}
return out + "\"";
}
sqlite3* handle = nullptr;
std::string rows;
};
import { initNative, Database } from './native/database.h';
import { catalogAsSql } from './catalog.js';
await initNative();
const db = await new Database();
await db.exec(catalogAsSql);
const rows = await db.query(`
`);
The first run downloads 1.5 MB of WebAssembly.Try in Playground →
Drop in prebuilt C and C++ libraries.
All 16 libraries →- GDALThe geospatial stack, 200+ raster and vector formats
- OpenSSLTLS and crypto, real https from a WASI command
- SQLiteThe database, in the browser and on device
- PROJCoordinate transforms with the EPSG database
- GEOSPlanar geometry: buffers, overlays, predicates
- libTIFFTIFF read/write with JPEG, ZSTD and LERC codecs
- WebPWebP encode and decode anywhere
- SpatiaLiteSpatial SQL on top of SQLite