Gun application boilerplate
This boilerplate is a good starting point for gun applications, or just for understanding how all the pieces fit together.
Important: Make sure you update the gun version to latest, as the package.json on this app becomes stale!
# Download the code
$ git clone https://github.com/gundb/gun-starter-app.git
# Install the dependencies
$ cd gun-starter-app
$ npm install
Once the code has been downloaded, you can easily start the server:
$ npm start
Under the hood, this is just running
node server.js
In two browser windows, open localhost:8080/index.html
.
Make sure your server is running!
There's a global gun reference you can access in the developer console called data
. Change the value on message
and it'll update in real-time on the other browser.
// Updates on the other browser window.
data.put({
message: 'updated value',
})
The code provided here is just the bare basics. It's intentionally framework agnostic to keep the example simple and reusable.
Now that you've got real-time data sync and a way to listen for changes, you can plug those change events into a UI tool/framework (like jQuery, React, Angular, etc.)
For reference, here are gun apps written with...
Have more questions? Send 'em our way on the gitter channel.