GunJS Starterkit Quickstart - amark/gun GitHub Wiki

Install

Node.js

npm i gun

Browser

<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>

Usage

Local Device

You don't need to participate with the network to use Gun. You can use it locally without any networking.

Node.js

import GUN from "gun"
// or
const GUN = require("gun")

Browser

const GUN = Gun()
// or
const GUN = new Gun()

Local Network

To use Gun on your local network, you will need a local relay peer server.

Relay peer server on Node.js

const server = require('http').createServer().listen(8080);
const gun = GUN({web: server});

Your local relay peer server must have the proper ports open. In the above example, that port is 8080 and uses the tcp protocol.

Peers

Node.js
import GUN from "gun"
// or
const GUN = require("gun")

Browser

const GUN = Gun()
// or
const GUN = new Gun()

Everywhere

We are working on a distributed DHT with bootstrapping relay peer servers, and more. For now, you must specify a relay peer server if you want your application to communicate with other peers in the network.

const GUN = new Gun( { peers: "https://peerserver.example.org/gun" } )

The /gun at the end of the URL is important

Quick Start

User

Login

SEA

⚠️ **GitHub.com Fallback** ⚠️