The official @duckdb/node-api package runs DuckDB inside Node.js, Bun or Deno. Use it to build your own dashboard, feed a static site or script your analyses in TypeScript.
In any Node.js project.
npm install @duckdb/node-apiREAD_ONLY guarantees nothing gets modified.
import { DuckDBInstance } from '@duckdb/node-api';
const instance = await DuckDBInstance.create('selfsync-db.duckdb', {
access_mode: 'READ_ONLY',
});
const connection = await instance.connect();getRowObjectsJson() returns plain objects, ready to be serialized or passed to a charting library.
const reader = await connection.runAndReadAll(`SELECT z_sport AS sport,
count(*) AS sessions,
round(sum(z_total_distance) / 1000, 1) AS km
FROM z_fit_session_mesgs
GROUP BY ALL
ORDER BY km DESC;`);
console.table(reader.getRowObjectsJson());connection.runAndReadAll(sql, values) and $1, $2… placeholders instead of concatenating strings.Wondering what a table or a column holds? Browse the FIT file reference.