-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
GunJS Starterkit Quickstart
Daniel Raeder edited this page Feb 1, 2023
·
1 revision
npm i gun
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
You don't need to participate with the network to use Gun. You can use it locally without any networking.
import GUN from "gun"
// or
const GUN = require("gun")
const GUN = Gun()
// or
const GUN = new Gun()
To use Gun on your local network, you will need a local relay peer server.
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.
import GUN from "gun"
// or
const GUN = require("gun")
const GUN = Gun()
// or
const GUN = new Gun()
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