Node.js
The DuckDB Node.js client can connect to MotherDuck with an md: connection string, so JavaScript and TypeScript applications can query MotherDuck directly.
How it works with MotherDuck
- Install the DuckDB Node.js client in your application.
- Create a MotherDuck access token and provide it through a connection string parameter or environment variable.
- Open an
md:connection and run SQL from your application code.
Example
import duckdb from '@duckdb/node-api';
const token = process.env.motherduck_token;
const instance = await duckdb.DuckDBInstance.create(`md:my_db?motherduck_token=${token}`);
const connection = await instance.connect();
const result = await connection.run('SELECT current_database()');