Skip to content
Daniel M edited this page Sep 18, 2017 · 4 revisions

Gun works out of the box with React Native.

Importing Gun

Use the minified version of Gun that is bundled with the standard distribution:

import Gun from 'gun/gun.min.js';

// Connect to a remote server
const gun = new Gun("https://your-gun-server.com/gun");

// use Gun as usual

Long Term Storage

In the browser, Gun will dump the graph into LocalStorage to achieve longer-term storage. On a Node server, it can dump into a JSON file or into another storage system via an adapter.

In React Native, if you want to retain application data for either offline use or for long-term storage on the device itself, you can plug Gun into a few community built adapters:

If you choose not to use any long-term storage option, that's totally fine. Gun will keep as much of the graph as possible in memory, which will be dumped every time the application is restarted.

A Tip for Local Development

Let's say you've got a Gun server running on a Node process on your machine; while you're developing your React Native application, you want to connect up to that server rather than some remote, production server over the internet. Instead of giving "localhost", provide the Local-Area-Network (LAN) IP address for your machine:

const gun = new Gun("http://192.168.0.01:gun");

This wiki is where all the GUN website documentation comes from.

You can read it here or on the website, but the website has some special features like rendering some markdown extensions to create interactive coding tutorials.

Please feel free to improve the docs itself, we need contributions!

Clone this wiki locally