Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Last active October 26, 2024 17:42
Show Gist options
  • Save mafintosh/80f28829b629befc051b2a6af307c903 to your computer and use it in GitHub Desktop.
Save mafintosh/80f28829b629befc051b2a6af307c903 to your computer and use it in GitHub Desktop.
var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
var swarm = require('webrtc-swarm')
var signalhub = require('signalhub')
feed.on('ready', function () {
var hub = signalhub(feed.discoveryKey.toString('hex'), ['https://signalhub.mafintosh.com'])
var sw = swarm(hub)
sw.on('peer', function (peer, id) {
console.log('connected to a new peer:', id)
peer.pipe(feed.replicate({encrypt: false})).pipe(peer)
})
})
@mueslie
Copy link

mueslie commented Feb 28, 2024

Do you have an example on how to use hypercore in the browser with persistent storage? I tried to load my data into the hyperbee with random-access-web and it got too big and crashed in firefox. The same data is already persistent in the webstorage idb and works without a problem.

I don't want to load all my data into the RAM every time I run the application and then replicate all changes back to the idb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment