Skip to main content

GUN Database

A realtime, decentralized, offline-first graph data synchronization engine. Build collaborative apps that work everywhere with end-to-end encryption.

Quick start

Get up and running with GUN in minutes.

1

Install GUN

Install GUN via npm, yarn, or use the CDN link directly in your HTML.
npm install gun
Or include via CDN:
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
2

Initialize GUN

Create a GUN instance to start syncing data across peers.
// In Node.js
const Gun = require('gun');
const gun = Gun();

// In browser (after CDN include)
const gun = Gun();
GUN works offline-first. Data syncs automatically when peers connect.
3

Store and retrieve data

Use GUN’s graph API to put and get data with realtime updates.
// Store data
gun.get('users').get('alice').put({
  name: 'Alice',
  age: 25
});

// Subscribe to realtime updates
gun.get('users').get('alice').on((data, key) => {
  console.log('Alice:', data);
});
Changes propagate in realtime to all connected peers automatically.
4

Explore advanced features

Add authentication, encryption, and P2P networking to your app.
// User authentication with SEA
const user = gun.user();
user.create('alice', 'password', (ack) => {
  if(ack.err) return console.log(ack.err);
  user.auth('alice', 'password');
});

Key features

Everything you need to build decentralized applications.

Realtime sync

Automatic P2P state synchronization with conflict-free updates across all peers

Graph database

Flexible graph structure supporting key/value, documents, tables, and relations

Offline-first

Works fully offline and syncs automatically when connectivity returns

Decentralized

No single point of failure with peer-to-peer mesh networking

End-to-end encryption

Built-in security with SEA for authentication, encryption, and signatures

High performance

20M+ API operations per second in just 9KB gzipped

Explore documentation

Learn core concepts, explore the API, and integrate GUN into your stack.

Core concepts

Understand graph databases, CRDTs, and decentralized architectures

API reference

Complete API documentation for all GUN methods and options

Security (SEA)

User authentication, encryption, and cryptographic operations

Integration guides

Use GUN with React, Vue, Angular, Node.js, and more

Ready to build decentralized apps?

Join thousands of developers using GUN to build collaborative, offline-first applications.

Start Building