Inspired by a similar project called GenosDB and Cloudflareβs initiative to rebuild Next.js, I decided to rebuild GunDB with a modern coding style, incorporating improvements and addressing shortcomings in the original technology. I used the OpenCode tool with the Big Pickle model to rewrite the project in a new graph database called Garfo (the Portuguese word for βforkβ), and I was impressed with the results and its practical applications. In this article, Iβll explain the technology and its improvements over GunDB.
Introduction
Garfo is a modern, browser-first fork of GUN.js β the decentralized, offline-first graph database. A fork of the original project that keeps the familiar GUN graph API while bringing meaningful improvements to the modern JavaScript ecosystem.
Why a Fork?
GUN.js is a revolutionary technology β a graph database that syncs in real time, works peer-to-peer, resolves conflicts automatically, and runs in the browser. However, the JavaScript ecosystem has evolved. TypeScript has become the standard, ES modules are the norm, and new transport layers like Nostr have emerged as promising decentralized protocols.
Garfo was born to fill these gaps: a GUN rewritten with modern typing, designed with the browser as a first-class citizen, and with native support for the Nostr protocol.
Key Features
Familiar Graph API
If you've used GUN before, you'll feel right at home. Garfo exposes the same chainable API:
import Garfo from 'garfo';
const db = new Garfo({ localStorage: true });
db.get('users').get('alice').put({
name: 'Alice',
status: 'online'
});
db.get('users').get('alice').on(profile => {
console.log('Update:', profile);
});
All the classic methods are there: get(), put(), set(), on(), once(), map().
Optional Nostr Transport
This is one of the most exciting additions. Garfo can use Nostr relays as a transport layer, allowing peers to exchange graph messages through public or private relays:
const db = new Garfo({
nostr: {
sk: 'private-key-hex',
relays: ['wss://relay.damus.io', 'wss://nos.lol'],
},
});
db.get('chat').get('general').set({
from: 'alice',
text: 'Hello over Nostr!',
timestamp: Date.now(),
});
IndexedDB and OPFS storage
In addition to localStorage, I have also included IndexedDB and OPFS as alternative ways to store database data in the browser
This unlocks immense possibilities: Garfo no longer depends solely on direct WebSocket connections β any Nostr relay can become a synchronization backbone.
SEA β Security, Encryption, Authorization
The SEA module is included, providing:
- Public/private key pairs for users
- End-to-end encryption
- Data signing and verification
- Proof-of-work for rate limiting
Browser-First
Unlike GUN.js which carries a Node.js legacy, Garfo is built with the browser as the primary target:
- Native
localStoragebackend support - Zero configuration to get started
- Web-optimized bundle
- TypeScript throughout
Use Cases
Garfo shines in local-first and decentralized applications:
- Peer-to-peer chat β the repo includes a complete Nostr-backed chat example with React + TypeScript
- Collaborative apps β document editing, Kanban boards, shared whiteboards
- P2P content delivery β the repo has a livestream example using peer-to-peer CDN
- Offline IoT β field data collection with sync when online
- Decentralized social networks β combining graph data model with Nostr transport
Example: Nostr Chat
The project ships with a working chat demo. Run npm start, open two browser tabs, and each creates a Nostr identity. Messages flow through relays and are stored locally:
git clone https://github.com/israelmarmar/garfodb.git
cd garfodb/examples/nostr-chat
npm install
npm start
# Open http://127.0.0.1:8900/ in two windows
The chat supports generating identities, copying public keys, backing up and restoring keys β recovering full history from relays.
How Garfo Compares
| Feature | GUN.js | Garfo |
|---|---|---|
| Package name | gun |
garfo |
| Constructor | Gun |
Garfo (with Gun alias) |
| TypeScript | Limited | Full |
| Nostr transport | β | β Native |
| Focus | Node + Browser | Browser-first |
| Storage | LocalStorage | LocalStorage, IndexedDB, OPFS |
| Maintenance | Original community | Active fork |
Technical Notes
Garfo retains the graph node architecture of original GUN. Each piece of data lives in a "soul" β a node identified by a unique key. Peers connect in a mesh and exchange graph deltas.
A key difference: while GUN.js was designed in a pre-TypeScript era, Garfo ships with complete types β you get intellisense and type checking out of the box.
Conclusion
If you're building a decentralized application and need a real-time syncing database without central servers, Garfo deserves your attention.
The project is already available in beta; not all security tests have been completed, so use it at your own risk
Links: GitHub Repository | GUN.eco | Nostr Protocol
| GenosDB
United States
NORTH AMERICA
Related News
Every Medium Publication That Accepts 3D Content (2026 Map)
14h ago

Agentic Ops: How I Shipped My Vibe-Coded Game to Production
14h ago
I build a project calculator web app for n8n / automation folks
14h ago
Integers and Floating-Point Numbers in C++
14h ago

How to Secure Azure Storage Using Managed Identities and RBAC
14h ago