-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Installation
GUN can be used in browsers, NodeJS, and mobile.
The easiest way is to just add GUN into your HTML:
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script>
gun = GUN(); // your code here
</script>
If you are using Webpack or other build tools, first follow the npm install, then add this to your browser code:
const GUN = require('gun/gun');
Same as with require
, but using the latest ES6 syntax:
import GUN from "https://cdn.skypack.dev/gun";
First you need to install GUN with NPM or other via the command line:
$npm install gun
Then add this to your server code:
const GUN = require('gun');
Note: GUN comes with many default NodeJS adapters for storage and networking. If you do not want these, just do
require('gun/gun')
instead.
We recommend using a 1-click deploy instead, or running npm start
inside of your local GUN repo. However, if you want to install GUN to an existing HTTP server, just pass it the server instance:
const server = require('http').createServer().listen(8080);
const gun = GUN({web: server});
Please see the HTTP(S) example, or Express in the same folder.
Or using --experimental-modules in NodeJS might make import GUN from './node_modules/gun/lib/server.js'
work.
- Try out the Hello World.
- Watch the 2 minute Crash Course?
- Hands-on learn answers to all your questions in THE INTERACTIVE TUTORIAL!