npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openbase-js

v0.1.9

Published

JavaScript client for Openbase — a self-hosted Supabase alternative

Readme

OpenBase JS SDK

The OpenBase JS SDK provides a lightweight, expressive interface for interacting with your OpenBase projects. It handles database queries (PostgreSQL), file storage (S3/MinIO), and realtime subscriptions via a simple, Supabase-like API.

📦 Installation

npm install openbase-js
# or
yarn add openbase-js

[!NOTE]
If you are using Node.js for file uploads, you will also need form-data:
npm install form-data

🚀 Quick Start

Initialize the client with your project URL, API key, and database name.

const { createClient } = require('openbase-js');

const openbase = createClient(
  'http://localhost:3003', // The URL where your OpenBase backend is running
  'your-anon-key',
  'your-db-name'
);

// Fetch data
async function getLeads() {
  const { data, error } = await openbase
    .from('leads')
    .select('*')
    .eq('status', 'active');
  
  if (error) console.error(error);
  else console.log(data);
}

📊 Database Operations

OpenBase uses a chainable query builder for database operations.

Basic CRUD

Select

const { data } = await openbase.from('users').select('id, username');

Insert

const { data } = await openbase.from('users').insert({
  username: 'jdoe',
  email: '[email protected]'
});

Update

const { data } = await openbase.from('users')
  .update({ email: '[email protected]' })
  .eq('id', 1);

Delete

const { data } = await openbase.from('users')
  .delete()
  .eq('id', 1);

🔍 Detailed Operator Guide

Filtering is done using chainable operator methods.

| Operator | Method | Description | Example | | :--- | :--- | :--- | :--- | | == | .eq(col, val) | Equal to | .eq('name', 'Alice') | | > | .gt(col, val) | Greater than | .gt('age', 21) | | < | .lt(col, val) | Less than | .lt('score', 50) | | >= | .gte(col, val) | Greater than or equal to | .gte('price', 100) | | <= | .lte(col, val) | Less than or equal to | .lte('stock', 5) | | LIKE | .like(col, pattern) | Case-sensitive pattern match | .like('name', '%son%') | | ILIKE | .ilike(col, pattern)| Case-insensitive pattern match | .ilike('name', '%SON%') | | IN | .in(col, array) | Contained in array | .in('role', ['admin', 'mod']) | | IS | .is(col, value) | Check for null or boolean | .is('deleted_at', null) |

🛠️ Modifiers

  • .order(column, { ascending: boolean }): Sort the results.
  • .limit(count): Limit the number of rows returned.
  • .range(from, to): Pagination (0-indexed, inclusive).
  • .single(): Returns a single object instead of an array.
const { data } = await openbase
  .from('posts')
  .select('*')
  .gt('likes', 10)
  .order('created_at', { ascending: false })
  .range(0, 9) // First 10 items

📁 Storage

OpenBase provides built-in S3-compatible storage.

Uploading Files

In the browser, you can pass a File or Blob. In Node.js, you can pass a file path, Buffer, or ReadStream.

// Browser
const file = event.target.files[0];
const { data, error } = await openbase.storage.upload(file, 'profile.jpg');

// Node.js (requires form-data)
const { data, error } = await openbase.storage.upload('./local-image.png', 'remote-name.png');

Listing & Managing Files

// List all files in bucket
const { data: files } = await openbase.storage.list();

// Get a public presigned URL (valid for 7 days)
const { data: { url } } = await openbase.storage.getUrl('profile.jpg');

// Remove a file
await openbase.storage.remove('profile.jpg');

🔄 Realtime

Subscribe to database changes using WebSockets.

const subscription = openbase
  .from('messages')
  .on('INSERT', (payload) => {
    console.log('New message:', payload.record);
  })
  .subscribe();

// To stop listening
// subscription.unsubscribe();

⌨️ TypeScript Support

The SDK is written with full TypeScript support. Types are automatically included.

interface Lead {
  id: number;
  company_name: string;
}

const { data } = await openbase.from<Lead>('leads').select('*');
// data is typed as Lead[] | null

🧪 Testing

To run the local tests:

  1. Ensure the OpenBase backend is running.
  2. Update the credentials in test.js.
  3. Run: node test.js