Skip to content


Jachen Duschletta edited this page Nov 7, 2019 · 19 revisions

GUN can be used in both browsers and servers. We have made it easy to install in many different environments.


There are a couple choices:

Script Tag

The easiest is to just add GUN into your HTML:

<script src=""></script>
  // your code here


Assuming you are using something like Webpack or Browserify, first follow the npm install, then add this to your browser code:

var Gun = require('gun/gun');


Same as with require, but using the latest ES6 syntax:

import Gun from 'gun/gun'

Note: For now, even though you import it, GUN is still defined and used as a global variable.


First you need to install GUN with NPM or Yarn via the command line:

$npm install gun or $yarn add gun

Note: If you don't have node or npm installed, read this.

Then add this to your server code:

var 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.


If you want to actually install GUN to a server, you need to pass it an HTTP instance:

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

We recommend you check out the default HTTP(S) example, or the Express and Hapi ones in the same folder.

Next up?

Note for ECMA Modules

In Node 12, if you use the --experimental-modules flag, you can use Import Gun from './node_modules/gun/lib/server.js' and that will do the trick for those of us who want to use ESM modules

!!! Attention !!!

Please read the docs at !

This wiki is only for editing to improve the docs.

Click on the "> Pages" button above to find the page to edit.

Or add a page with "New Page" button.

!!! Attention !!!

Clone this wiki locally
You can’t perform that action at this time.