amark /gun
An open source cybersecurity protocol for syncing decentralized graph data.
★ 19,157⑂ 1,245👁 303⑃ 606● 815▤ 17
-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 introTop issues
#70Documentation49 comments · 2015-07-08#259Initiate Data Handshake on Reconnect40 comments · 2016-11-01#321ACL, Authentication, Security, Permissions, Authorization, etc.34 comments · 2017-02-22#1370AI Maintenance Effort & Pipeline: Issue Resolution, PRs, Documentation, Ports26 comments · 2024-03-31#426.put not saving/changing anything in a difficult edge case20 comments · 2017-09-25#681.once not triggering consistently when Gun is used inside a ServiceWorker18 comments · 2019-01-09#620GUN crashed in middle of IA demo ! 18 comments · 2018-10-04#541.off() unsubscribes completely for session18 comments · 2018-05-18