Node.js Bindings

GlareDB binaries are distributed through npm, along with Node.js language bindings. There are two ways to use GlareDB:

  • locally, with optional disk persistence. In this scenario, queries are executed entirely in-process, and data exists in-memory or on-disk.

  • hybrid, with GlareDB Cloud. In this scenario, queries are partitioned and optimized to run both in-process and using cloud compute. Data can be accessed and stored in cloud. When using GlareDB Cloud, you can access your data in all of your applications.

TypeScript types are added by default, and so GlareDB can be used with either JavaScript or TypeScript out of the box.


The glaredb module is available on npm To install the module:

npm i @glaredb/glaredb

or, with yarn:

yarn add @glaredb/glaredb

After running npm i @glaredb/glaredb, the contents are added to node_modules/@glaredb. There will be two subdirectories:

  • glaredb - which contains language bindings and code that loads and runs the binary
  • glaredb-[platform]-[arch] - this is a platform-specific GlareDB binary


Import (ESM) or require (CJS) the @glaredb/glaredb module, then open a connection using connect. Opening a connection starts, and interfaces with the GlareDB binary.

// ESM
import glaredb from "@glaredb/glaredb";

const con = await glaredb.connect();
const res = await con.sql("SELECT 'hello JS'");

// CommonJS
const glaredb = require("@glaredb/glaredb");

const con = await glaredb.connect();
const res = await con.sql("SELECT 'hello JS'");


When calling connect without any arguments, all data will exist in-memory and will not persist once the process ends.

const con = await glaredb.connect();

To persist data locally, specify a location as the first argument:

const con = await glaredb.connect("./temp-dir");

Hybrid with GlareDB Cloud

Provide a connection string to connect with GlareDB Cloud.

import glaredb from "@glaredb/glaredb";

const str = "glaredb://";
const con = await glaredb.connect(str);

const res = await con.sql("select * from cloud_table");

By connecting with GlareDB Cloud, you can access both local and cloud data. For example, assuming you have a table in the cloud called cloud_table, and a local JSON file called report.json:

const res = await con.sql(`
SELECT * FROM cloud_table ct
JOIN './report.json' r ON =;

For more information, refer to our in-depth blog post Working with Node.js.