Kolaybase + Node.js: Backend Data Access from the Server

From Node.js you can run trusted server-side logic against Kolaybase — background jobs, webhooks, scripts, and APIs — using a service key for full access.

Install

npm install kolaybase-js

Create a server client

// kolaybase.js
import { createClient } from "kolaybase-js";

export const kb = createClient({
  projectId: process.env.KOLAYBASE_PROJECT_ID,
  apiKey: process.env.KOLAYBASE_SERVICE_KEY, // server-only
});

On the server you can use a service key for trusted operations that bypass row-level security. Never expose a service key to the browser.

Run a query or raw SQL

import { kb } from "./kolaybase.js";

// Query builder
const { data } = await kb.from("users").select("id, email").eq("active", true);

// Or raw SQL for reports (sanitize any dynamic input!)
const { data: stats } = await kb.sql(
  "select plan, count(*) from subscriptions group by plan",
);

Trusted server access

Use a service key for jobs and admin tasks that need to bypass row-level security.

Raw SQL when you need it

Run reports and complex queries with kb.sql, in addition to the query builder.

Same SDK everywhere

Share data-access code between your server and client where appropriate.

Frequently asked questions

Can I run background jobs against Kolaybase?
Yes. Use a Node.js process with a service key to run scheduled jobs, process webhooks, or perform admin operations.
When should I use a service key vs. the anon key?
Use the service key only on trusted servers for operations that must bypass row-level security. Use the anon key for anything reachable by the browser.

Other integrations

Build your Node.js backend on Kolaybase

PostgreSQL, auth, storage, and a REST API — running in minutes.

Get started