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

hxdb-react

v0.1.2

Published

React client library for HxDB - Query your database with React components

Readme

hxdb-react

React client library for HxDB — query your database with React hooks and components.

Install

npm install hxdb-react

Quick Start

1. Wrap your app with the provider

The baseUrl defaults to https://hxdb-test.kubo.hexabase.io, so you only need to provide your API key:

// app/providers.tsx (Next.js App Router)
"use client";
import { HxDBProvider } from "hxdb-react";

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <HxDBProvider config={{ apiKey: "your-api-key" }}>
      {children}
    </HxDBProvider>
  );
}

To connect to a different HxDB instance, override baseUrl:

<HxDBProvider config={{ baseUrl: "http://localhost:5213", apiKey: "your-api-key" }}>
  {children}
</HxDBProvider>

2. Wire up the layout

// app/layout.tsx
import { Providers } from "./providers";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

3. Query with the useHxDB hook

"use client";
import { useHxDB } from "hxdb-react";

interface User {
  id: number;
  name: string;
  email: string;
}

export default function UserList() {
  const { data, columns, loading, error, executionTimeMs } = useHxDB<User>(
    "SELECT * FROM users LIMIT 10"
  );

  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error}</p>;

  return (
    <div>
      <p>Fetched in {executionTimeMs}ms</p>
      <table>
        <thead>
          <tr>
            {columns.map((col) => (
              <th key={col}>{col}</th>
            ))}
          </tr>
        </thead>
        <tbody>
          {data.map((user) => (
            <tr key={user.id}>
              <td>{user.id}</td>
              <td>{user.name}</td>
              <td>{user.email}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}

4. Or use the declarative <HxDB> component

"use client";
import { HxDB } from "hxdb-react";

export default function OrdersTable() {
  return (
    <HxDB query="SELECT * FROM orders ORDER BY created_at DESC LIMIT 20">
      {({ data, loading, error, columns, refetch }) => {
        if (loading) return <p>Loading...</p>;
        if (error) return <p>Error: {error}</p>;

        return (
          <div>
            <button onClick={refetch}>Refresh</button>
            <table>
              <thead>
                <tr>
                  {columns.map((c) => (
                    <th key={c}>{c}</th>
                  ))}
                </tr>
              </thead>
              <tbody>
                {data.map((row, i) => (
                  <tr key={i}>
                    {columns.map((c) => (
                      <td key={c}>{String(row[c] ?? "")}</td>
                    ))}
                  </tr>
                ))}
              </tbody>
            </table>
          </div>
        );
      }}
    </HxDB>
  );
}

API Reference

<HxDBProvider>

Wraps your app and provides the HxDB client to all child components.

| Prop | Type | Required | Description | |------|------|----------|-------------| | config.baseUrl | string | No | HxDB server URL (default: https://hxdb-test.kubo.hexabase.io) | | config.apiKey | string | Yes | API key for authentication (from Settings page) | | config.headers | Record<string, string> | No | Custom request headers |

useHxDB<T>(query, options?)

React hook for executing SQL queries.

const { data, columns, loading, error, executionTimeMs, rowsAffected, refetch } = useHxDB<User>(
  "SELECT * FROM users",
  { enabled: true } // set false to defer execution
);

Returns HxDBQueryState<T>:

| Field | Type | Description | |-------|------|-------------| | data | T[] | Query result rows | | columns | string[] | Column names | | loading | boolean | Loading state | | error | string \| null | Error message | | executionTimeMs | number \| null | Query execution time | | rowsAffected | number | Rows affected (INSERT/UPDATE/DELETE) | | refetch | () => Promise<void> | Re-execute the query |

<HxDB>

Declarative component using render props pattern.

<HxDB query="SELECT * FROM products" enabled={true}>
  {({ data, loading, error }) => {
    // render your UI
  }}
</HxDB>

HxDBClient

Standalone client for use outside React components (API routes, scripts, etc).

import { createHxDBClient } from "hxdb-react";

// Uses default URL (https://hxdb-test.kubo.hexabase.io)
const client = createHxDBClient({ apiKey: "your-api-key" });

// Or specify a custom URL
// const client = createHxDBClient({ baseUrl: "http://localhost:5213", apiKey: "your-api-key" });

// Query
const { data, columns } = await client.query("SELECT * FROM users LIMIT 5");

// List datasets
const datasets = await client.datasets();

cURL Examples

The same API works with any HTTP client:

# Query with API key
curl -X POST https://hxdb-test.kubo.hexabase.io/api/query \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{"sql": "SELECT * FROM users LIMIT 5"}'

# List datasets
curl https://hxdb-test.kubo.hexabase.io/api/datasets \
  -H "Authorization: Bearer your-api-key"

# Get dataset schema
curl https://hxdb-test.kubo.hexabase.io/api/datasets/users/schema \
  -H "Authorization: Bearer your-api-key"

# Insert a row
curl -X POST https://hxdb-test.kubo.hexabase.io/api/datasets/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{"name": "Alice", "email": "[email protected]"}'

License

MIT