Serverless functions triggered by ZeroDB database events. Drop-in replacement for @supabase/functions-js.
Zero dependencies. Works with Node.js 18+, Deno, Bun, and Cloudflare Workers.
npm install @zerodb/functions-jsimport { ZeroDBFunctions } from '@zerodb/functions-js';
const functions = new ZeroDBFunctions({
apiKey: process.env.ZERODB_API_KEY,
});
// Create a function triggered by database events
const { data, error } = await functions.create('auto-embed', {
trigger: 'zerodb.vector.stored',
hookConfig: { model: 'bge-m3' },
});
// Invoke a function
const { data: result } = await functions.invoke('auto-embed', {
body: { text: 'Hello, World!' },
});
// List all functions
const { data: fns } = await functions.list();
// Update a function
await functions.update('auto-embed', {
hookConfig: { model: 'text-embedding-3-small' },
});
// Delete a function
await functions.delete('auto-embed');| Option | Type | Required | Default |
|---|---|---|---|
apiKey |
string |
Yes | — |
baseUrl |
string |
No | https://api.ainative.studio |
projectId |
string |
No | — |
headers |
object |
No | {} |
fetch |
function |
No | globalThis.fetch |
All methods return Promise<{ data, error }>.
Register a function triggered by a ZeroDB event.
await functions.create('on-vector-store', {
trigger: 'zerodb.vector.stored', // required
hookConfig: { /* handler config */ },
projectId: 'proj-123', // optional, scopes to project
});Invoke a function by name.
const { data, error } = await functions.invoke('my-function', {
body: { key: 'value' },
headers: { 'X-Custom': 'yes' },
});List registered functions.
const { data } = await functions.list({
eventType: 'zerodb.vector.stored', // filter by event
activeOnly: true, // default: true
});Get a single function by UUID.
Update a function by name or UUID.
await functions.update('my-function', {
hookConfig: { url: 'https://new-webhook.example.com' },
isActive: false,
});Delete a function by name or UUID.
| Event | Description |
|---|---|
zerodb.vector.stored |
A vector embedding was stored |
zerodb.vector.deleted |
A vector was deleted |
zerodb.memory.stored |
A memory was stored via ZeroMemory |
zerodb.memory.recalled |
A memory was recalled |
zerodb.table.row_inserted |
A row was inserted into a NoSQL table |
zerodb.table.row_updated |
A row was updated |
zerodb.table.row_deleted |
A row was deleted |
zerodb.file.uploaded |
A file was uploaded to storage |
import { FunctionsHttpError, FunctionsFetchError } from '@zerodb/functions-js';
const { data, error } = await functions.invoke('my-fn');
if (error instanceof FunctionsHttpError) {
console.log('HTTP error:', error.status, error.message);
} else if (error instanceof FunctionsFetchError) {
console.log('Network error:', error.message);
}| Supabase | ZeroDB |
|---|---|
supabase.functions.invoke('hello') |
functions.invoke('hello') |
Deploy via CLI (supabase functions deploy) |
functions.create('hello', { trigger: '...' }) |
| Manual function files | Event-driven hooks, auto-provisioned |
Deno.serve(...) handler |
Hook config points to handler |
Key difference: ZeroDB functions are event-driven by default. Instead of deploying code files, you register hooks that trigger on database events. The handler runs in ZeroDB's sandboxed executor.
// Supabase
const { data, error } = await supabase.functions.invoke('hello', {
body: { name: 'World' },
});
// ZeroDB — same API shape
const { data, error } = await functions.invoke('hello', {
body: { name: 'World' },
});const { ZeroDBFunctions } = require('@zerodb/functions-js');- Sign up at zerodb.dev
- Create a project
- Copy your API key from the dashboard
Or use the CLI:
npx zerodb-cli initMIT
This package is part of the AINative ecosystem — the AI-native developer platform.
| Feature | ZeroDB | Others |
|---|---|---|
| Vector search | Built-in, free embeddings | Separate service (Pinecone, Qdrant) |
| Agent memory | Cognitive memory with decay + reflection | DIY or Mem0 ($$$) |
| File storage | S3-compatible, included | Separate S3 bucket |
| NoSQL tables | Instant, schema-free | MongoDB Atlas, DynamoDB |
| PostgreSQL | Managed, pgvector pre-installed | Neon, Supabase ($$$) |
| Serverless functions | DB-event triggered | Firebase/Supabase Edge |
| Pricing | Free tier, no credit card | Pay-per-query from day 1 |
npx zerodb-cli init # Auto-configures your IDEOr sign up at ainative.studio — free tier, no credit card required.
No account needed to start. On first run, this package automatically:
- Provisions a free ZeroDB instance (~800ms)
- Saves credentials locally (
.env,.mcp.json) - Prints a claim link in your terminal
Your auto-provisioned instance is free for 72 hours. To keep your data permanently, visit the claim URL printed in your terminal.
If a coding agent (Claude Code, Cursor, Windsurf) installs this package:
- Auto-provisions without human intervention
- The claim URL appears in agent output — visit it to take ownership
.claude/CLAUDE.mdinstructs agents to surface the claim link to you- Check
.envor~/.ainative/config.jsonfor your project ID if you miss it