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

zerodb-firebase

v1.0.0

Published

Firebase Cloud Functions compatible SDK backed by ZeroDB. Same syntax, zero vendor lock-in.

Readme

zerodb-firebase

Firebase Cloud Functions compatible SDK backed by ZeroDB. Same trigger syntax you already know, zero vendor lock-in, instant setup.

npm install zerodb-firebase

Why migrate?

| | Firebase | zerodb-firebase | |---|---|---| | Setup time | Project + billing + deploy | npm install and go | | Vendor lock-in | Full Google ecosystem | Open API, swap anytime | | Auto-provisioning | No | Yes, instant (no signup) | | Cold starts | 1-10s | Sub-100ms (edge hooks) | | Pricing | Pay per invocation + storage | Free tier, then usage-based | | Firestore required | Yes | No, any ZeroDB table |

Quick start

import { onDocumentCreated, onDocumentUpdated, deployTriggers } from 'zerodb-firebase';

// Same Firebase syntax, ZeroDB backend
export const onUserCreated = onDocumentCreated('users/{userId}', (event) => {
  const snapshot = event.data;
  const userData = snapshot.data();
  console.log('New user:', userData.name);
  console.log('User ID:', event.params.userId);
});

export const onProfileUpdated = onDocumentUpdated('users/{userId}', (event) => {
  const before = event.data.before.data();
  const after = event.data.after.data();
  console.log('Name changed:', before.name, '->', after.name);
});

// Deploy all triggers to ZeroDB
await deployTriggers();

That's it. If you don't set ZERODB_API_KEY and ZERODB_PROJECT_ID, a free project is auto-provisioned on first deploy.

Firebase migration guide

Step 1: Replace imports

- import { onDocumentCreated } from 'firebase-functions/v2/firestore';
+ import { onDocumentCreated } from 'zerodb-firebase';

Step 2: Keep your handlers exactly the same

// This code works with BOTH firebase-functions and zerodb-firebase
export const onOrderPlaced = onDocumentCreated('orders/{orderId}', async (event) => {
  const order = event.data.data();
  const orderId = event.params.orderId;

  // Send confirmation email
  await sendEmail(order.customerEmail, `Order ${orderId} confirmed!`);

  // Update inventory
  for (const item of order.items) {
    await updateInventory(item.sku, -item.quantity);
  }
});

Step 3: Deploy

import { deployTriggers } from 'zerodb-firebase';

// Deploy all registered triggers to ZeroDB hooks
await deployTriggers({
  apiKey: process.env.ZERODB_API_KEY,      // optional: auto-provisions if missing
  projectId: process.env.ZERODB_PROJECT_ID, // optional: auto-provisions if missing
});

Step 4: Process incoming events

When ZeroDB fires a hook, route the webhook payload to processEvent:

import { processEvent } from 'zerodb-firebase';
import express from 'express';

const app = express();
app.use(express.json());

app.post('/webhooks/zerodb', async (req, res) => {
  const results = await processEvent(req.body);
  res.json({ results });
});

app.listen(3000);

API reference

Trigger builders

All trigger builders follow the same signature as firebase-functions/v2/firestore:

import {
  onDocumentCreated,   // Fires on new row insert
  onDocumentUpdated,   // Fires on row update (provides before/after)
  onDocumentDeleted,   // Fires on row delete
  onDocumentWritten,   // Fires on any write (create, update, delete)
} from 'zerodb-firebase';

Path patterns use Firebase-style wildcards:

onDocumentCreated('users/{userId}', handler);
onDocumentCreated('orders/{orderId}/items/{itemId}', handler);
onDocumentCreated('logs', handler); // No wildcards

Options object (alternative to string path):

onDocumentCreated({
  document: 'users/{userId}',
  callbackUrl: 'https://myapp.com/webhooks/zerodb',
}, handler);

Event object

Handlers receive a FirestoreEvent:

onDocumentCreated('users/{userId}', (event) => {
  event.data;       // DocumentSnapshot (created/deleted) or Change (updated/written)
  event.params;     // { userId: 'abc123' }
  event.type;       // 'document.created'
  event.id;         // Row ID
  event.path;       // 'users/abc123'
  event.time;       // ISO timestamp
});

DocumentSnapshot

const snapshot = event.data;
snapshot.data();         // Full document data
snapshot.exists;         // true if data is not null
snapshot.id;             // Document ID
snapshot.ref.path;       // Full path
snapshot.get('name');    // Get field by path (supports dot notation)
snapshot.get('addr.city'); // Nested field access

Change (for update/write triggers)

onDocumentUpdated('users/{userId}', (event) => {
  const change = event.data;
  change.before;   // DocumentSnapshot of old data
  change.after;    // DocumentSnapshot of new data

  const oldName = change.before.data().name;
  const newName = change.after.data().name;
});

Runtime functions

import {
  deployTriggers,         // Deploy all triggers to ZeroDB hooks
  processEvent,           // Route a webhook event to matching handlers
  initializeApp,          // Initialize with explicit config
  clearTriggers,          // Clear all registered triggers
  getRegisteredTriggers,  // List all registered triggers
} from 'zerodb-firebase';

initializeApp

import { initializeApp } from 'zerodb-firebase';

// Mirrors firebase-admin.initializeApp()
initializeApp({
  apiKey: 'zdb_your_key',
  projectId: 'your-project-id',
  baseUrl: 'https://api.ainative.studio', // optional
});

Event type mapping

| Firebase event | ZeroDB hook event | |---|---| | document.created | zerodb.table.row_inserted | | document.updated | zerodb.table.row_updated | | document.deleted | zerodb.table.row_deleted | | document.written | zerodb.table.row_written |

Environment variables

| Variable | Description | Required | |---|---|---| | ZERODB_API_KEY | ZeroDB API key | No (auto-provisions) | | ZERODB_PROJECT_ID | ZeroDB project ID | No (auto-provisions) | | ZERODB_BASE_URL | API base URL | No (defaults to https://api.ainative.studio) |

CommonJS support

const { onDocumentCreated, deployTriggers } = require('zerodb-firebase');

Powered by ZeroDB + AINative

| Feature | Details | |---|---| | Auto-provisioning | No signup needed. First deploy creates a free project. | | Free tier | 10K events/month, 1GB storage | | Edge hooks | Sub-100ms trigger execution | | Zero vendor lock-in | Standard HTTP webhooks, export anytime | | MCP compatible | Works with Claude Code, Cursor, Windsurf |

Get started free: ainative.studio

Built by AINative Studio -- the database for AI agents.