Skip to main content
GUN is an ecosystem of tools that let you build community-run and encrypted applications - like an open source Firebase or a decentralized Dropbox. GUN Demo

What is GUN?

GUN is a graph synchronization protocol with a lightweight embedded engine, capable of doing 20M+ API ops/sec in just ~9KB gzipped size. The Internet Archive and hundreds of other apps run GUN in production, processing terabytes of daily P2P traffic.
GUN was created by Mark Nadal in 2014 after spending 4 years trying to get collaborative web apps to scale with traditional databases. The goal was to build a P2P database that could survive inside any browser and correctly sync data between any device after any offline-first activity.

Key features

GUN provides several powerful capabilities that make it unique:

Realtime synchronization

Multiplayer by default with realtime peer-to-peer state synchronization across all connected devices

Graph data structure

Use key/value pairs, tables, documents, videos, and more - all in a flexible graph structure

Offline-first

Local-first architecture with offline support and automatic synchronization when reconnected

Decentralized

No master servers, no single source of truth - data syncs peer-to-peer with end-to-end encryption

How GUN works

Unlike traditional master-slave database architectures that create bottlenecks, GUN operates as a distributed graph database:
  • No master - No servers, no “single source of truth”
  • All data types - Not just SQL or NoSQL, but graphs, documents, tables, and key/value
  • Offline-first - Works in any browser and syncs correctly after offline activity
  • Conflict resolution - Uses CRDT algorithms to handle concurrent updates
  • Modular stack - Includes cryptographic security, storage serialization, mesh networking, and more
GUN Stack GUN Layers

Use cases

GUN powers decentralized alternatives to many popular services:

Chat applications

Real-time messaging with offline support

Collaborative tools

Shared documents and workspaces

Social networks

Decentralized social platforms like Iris

Video conferencing

P2P video calls like Meething

IoT devices

Distributed sensor networks

Gaming

Multiplayer games with P2P sync

Example: Basic data operations

Here’s a quick example showing GUN’s simplicity:
// Initialize GUN
gun = GUN();

// Store data
gun.get('mark').put({
  name: "Mark",
  email: "mark@gun.eco",
});

// Subscribe to realtime updates
gun.get('mark').on((data, key) => {
  console.log("realtime updates:", data);
});

// Update data continuously
setInterval(() => { 
  gun.get('mark').get('live').put(Math.random()) 
}, 9);

Example: Graph relationships

GUN handles circular references and graph traversal naturally:
cat = {name: "Fluffy", species: "kitty"};
mark = {boss: cat};
cat.slave = mark;

// Partial updates merge with existing data!
gun.get('mark').put(mark);

// Access data as if it is a document
gun.get('mark').get('boss').get('name').once(function(data, key){
  console.log("Mark's boss is", data);
});

// Traverse a graph of circular references!
gun.get('mark').get('boss').get('slave').once(function(data, key){
  console.log("Mark is the cat's slave!", data);
});

// Add both to a table!
gun.get('list').set(gun.get('mark').get('boss'));
gun.get('list').set(gun.get('mark'));

// Grab each item from the table, continuously:
gun.get('list').map().once(function(data, key){
  console.log("Item:", data);
});
Try these examples live in the JSBin playground or explore the interactive tutorial.

The NoDB philosophy

GUN challenges traditional database conventions:
  • No master-slave architecture - Eliminates single points of failure
  • No DevOps required - Runs anywhere JavaScript runs
  • No locking - CRDT-based conflict resolution
  • No language barriers - Built for the web, works everywhere
Database Comparison

Community and ecosystem

GUN is built by a friendly community of developers creating a free, fun future. The ecosystem includes:
  • SEA (Security, Encryption, Authorization) - Cryptographic security and user authentication
  • AXE - Mesh networking and routing algorithms
  • RAD - Radix storage serialization
  • Modules - GraphQL, Vue, React, Svelte, Angular integrations and more

Join the chat

Get help from the friendly GUN community

View examples

Explore real-world GUN applications

Next steps

Ready to start building with GUN?

Quickstart

Get up and running in 5 minutes

Installation

Install GUN for your platform