explaingit

amark/gun

19,037JavaScriptAudience · developerComplexity · 3/5MaintainedSetup · easy

TLDR

A peer-to-peer JavaScript database that syncs data in real time between devices without a central server, with built-in encryption.

Mindmap

mindmap
  root((repo))
    What it does
      Peer-to-peer sync
      Graph database
      Real-time updates
      End-to-end encryption
    How it works
      Browser and Node.js
      Offline-first design
      Optional relay servers
      Automatic propagation
    Use cases
      Collaborative apps
      Multiplayer games
      Chat and messaging
      Offline-capable apps
    Tech stack
      JavaScript
      npm package
      Graph structure
      Decentralized

Things people build with this

USE CASE 1

Build a collaborative document editor where multiple users edit the same file in real time without a central server.

USE CASE 2

Create a chat app that works offline and automatically syncs messages when devices reconnect.

USE CASE 3

Develop a multiplayer game where player state is synchronized across peers without relying on a game server.

USE CASE 4

Build a note-taking app that keeps working when the internet is down and syncs changes once connectivity returns.

Tech stack

JavaScriptNode.jsnpm

Getting it running

Difficulty · easy Time to first run · 5min
License could not be detected automatically. Check the repository's LICENSE file before use.

In plain English

GUN is an open-source JavaScript database and synchronization library designed for decentralized, peer-to-peer applications. Most databases live on a central server that everyone connects to. GUN flips that model: data can be stored and synchronized directly between users' devices (browsers, phones, servers) in real time, with no central server required, though you can use relay servers to help peers find each other. It stores data as a graph (a flexible structure that handles not just simple key-value pairs, but also tables, nested documents, and relationships between pieces of data). Changes made on one device automatically propagate to all other connected peers instantly. It also includes built-in end-to-end encryption, meaning data can be secured so only the intended parties can read it. You would use GUN when you are building an app that needs real-time collaboration between users (like a chat app, shared document, or multiplayer game), when you want the app to keep working offline and sync when connectivity resumes, or when you want to avoid dependency on a central cloud database. It runs in both the browser and Node.js, is installable via npm, and describes itself as a decentralized alternative to services like Firebase.

Copy-paste prompts

Prompt 1
Show me how to set up GUN in a Node.js project and create a simple real-time chat between two peers.
Prompt 2
How do I use GUN to build an offline-first todo app that syncs across my browser and phone?
Prompt 3
Explain how to encrypt data in GUN so only specific users can read it.
Prompt 4
Give me a working example of a GUN app that works without any central server.
Prompt 5
How do I add a relay server to help peers discover each other in a GUN network?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.