amark /gun

An open source cybersecurity protocol for syncing decentralized graph data.

★ 19,157⑂ 1,245👁 303⑃ 606● 815▤ 17
JavaScriptNOASSERTIONCreated 2014-07-31gun.eco/docs
下载:out of date, use npm or cdn for latestout-0.2019.413 ↓0.2019.4132019-04-15
-2
日增长
19,157
stars
1,245
forks
303
watchers
606
prs
815
issues
17
releases

README

!Build


GUN is an ecosystem of tools that let you build community run and encrypted applications - like an Open Source Firebase or a Decentralized Dropbox.

The Internet Archive and 100s of other apps run GUN in-production.

 + Multiplayer by default with realtime p2p state synchronization!
 + Graph data lets you use key/value, tables, documents, videos, & more!
 + Local-first, offline, and decentralized with end-to-end encryption.

Decentralized alternatives to Zoom, Reddit, Instagram, Slack, YouTube, Stripe, Wikipedia, Facebook Horizon and more have already pushed terabytes of daily P2P traffic on GUN. We are a friendly community creating a free fun future for freedom:



















 Quickstart

GUN is super easy to get started with:

 - Try the interactive tutorial in the browser (5min ~ average developer).
 - Or npm install gun and run the examples with cd node_modules/gun && npm start (5min ~ average developer).

 Note: If you don't have node or npm, read this first.
 If the npm command line didn't work, you may need to mkdir node_modules first or use sudo.

- An online demo of the examples are available here: http://try.axe.eco/
- Or write a quick app: (try now in a playground)
html


// import GUN from 'gun'; // in ESM
// GUN = require('gun'); // in NodeJS
// GUN = require('gun/gun'); // in React
gun = GUN();

gun.get('mark').put({
  name: "Mark",
  email: "[email protected]",
});

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

setInterval(() = { gun.get('mark').get('live').put(Math.random()) }, 9);


- Or try something mind blowing, like saving circular references to a table of documents! (play)
javascript
cat = {name: "Fluffy", species: "kitty"};
mark = {boss: cat};
cat.slave = mark;

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

// access the data as if it is a document.
gun.get('mark').get('boss').get('name').once(function(data, key){
  // once grabs the data once, no subscriptions.
  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 of them to a table!
gun.get('list').set(gun.get('mark').get('boss'));
gun.get('list').set(gun.get('mark'));

// grab each item once from the table, continuously:
gun.get('list').map().once(function(data, key){
  console.log("Item:", data);
});

// live update the table!
gun.get('list').set({type: "cucumber", goal: "jumping cat"});


Want to keep building more? Jump to THE DOCUMENTATION!

 About
First & foremost, GUN is a community of the nicest and most helpful people out there. So I want to invite you to come tell us about what you are working on & wanting to build (new or old school alike! Just be nice as well.) and ask us your questions directly. :)

Watch the 100 second intro

Top issues

Latest release

out of date, use npm or cdn for latest 0.2019.413 2019-04-15

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON