Get started with gun CDN

(Zlib OR MIT OR Apache-2.0) licensed

The Gun library is a real-time, distributed database for JS applications.

Tags:
  • gun
  • gunDB
  • graph
  • document
  • key
  • value
  • relational
  • datastore
  • database
  • engine
  • realtime
  • decentralized
  • peer-to-peer
  • distributed
  • P2P
  • OSS
  • embedded
  • localstorage
  • S3

Stable version

Copied!

How to start using gun CDN


// Include the gun library from the CDN
const Gun = require('gun/src/gun');
const SeaStore = require('gun/sea-store/sea-store');

// Initialize a new Gun instance with SeaStore
const gun = Gun({ sea: new SeaStore('https://sea.gun.dev/gun-chat') });

// Create a public chat room
const chatRoom = gun.get('chat');

// Set up a listener for new messages
chatRoom.on('update', (msg) => {
  console.log('New message:', msg.text);
});

// Send a new message to the chat room
const sendMessage = (text) => {
  chatRoom.put({ text });
};

// Example usage
sendMessage('Hello, world!');
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions