Integrate Hyperswarm in React-Native, iOS and Android
Firstly, refer to below repos if you get lost
- Main layer for communication
- This is bare-expo example that bare runtime is integrated and we can use it
- This is the main part which is where we will begin from
- If you would like to use any hyper modules on mobile then above repository bare-link is the one which comes very handy
- After installing hyperswarm to the project, we need to run a simple command
bare-pack --platform ios --linked --out app.bundle.mjs app.js
- So you could use simple code under
app.js
const Hyperswarm = require('hyperswarm');
const swarm = new Hyperswarm();
swarm.on('connection', conn => {
conn.on('data', data => {
console.log(data.toString());
});
conn.write("Hello from bare");
});
const topic = Buffer.alloc(32).fill('hello world')
swarm.join(topic)
console.log('Hello iOS!')
- Once you run the above command you're done and go to use hyperswarm accordingly.