Skip to content

Latest commit

 

History

History

README.md

HyperDHT in React Native - Documentation Suite

This folder contains comprehensive documentation about running Hyperswarm/HyperDHT in React Native using Bare Kit.


📚 Documents in This Folder

The Problem

Explains why Hyperswarm/HyperDHT doesn't work in standard React Native:

  • UDP socket requirements
  • Mobile platform limitations
  • Architectural constraints
  • Available networking APIs comparison

Read this first to understand the technical challenge.


Quick Reference

A concise TL;DR of the Bare Kit solution:

  • How it works (in brief)
  • Key differences table
  • Implementation steps overview
  • Quick comparison with alternatives

Read this for a fast overview before diving deeper.


The Solution (Detailed)

Complete architectural explanation of how Bare Kit enables Hyperswarm in React Native:

  • Bare Kit architecture deep dive
  • How bitcoin-tribe implements it
  • Worklet runtime vs React Native runtime
  • IPC/RPC communication patterns
  • Code examples and diagrams
  • Advantages and trade-offs
  • Comparison with other solutions

Read this to fully understand the solution architecture.


4. IMPLEMENTATION_GUIDE.md (25 KB) ⭐⭐

Production-Ready Implementation Guide

Complete implementation guide with clean, maintainable code:

  • Proper file structure and naming
  • Full TypeScript type safety
  • Clean state management patterns
  • Type-safe RPC commands with enums
  • Step-by-step instructions
  • Complete code examples (ready to use)
  • Build, test, and troubleshooting guides
  • Performance optimization tips
  • Better error handling
  • Comparison with bitcoin-tribe approach

Follow this when you're ready to implement with production-quality code.


🎯 Reading Order

If you're new to this topic:

  1. Start with BARE_KIT_SUMMARY.md (quick overview)
  2. Read WHY_HYPERDHT_NOT_IN_REACT_NATIVE.md (understand the problem)
  3. Study BARE_KIT_SOLUTION.md (learn the solution)
  4. Follow IMPLEMENTATION_GUIDE.md (implement with production code)

If you want to implement quickly:

  1. Skim BARE_KIT_SUMMARY.md (quick context)
  2. Jump to IMPLEMENTATION_GUIDE.md (start coding with clean examples)
  3. Reference BARE_KIT_SOLUTION.md (when you need architectural details)

If you want deep understanding:

  1. Read WHY_HYPERDHT_NOT_IN_REACT_NATIVE.md (the problem)
  2. Study BARE_KIT_SOLUTION.md thoroughly (the solution)
  3. Follow IMPLEMENTATION_GUIDE.md (implement with best practices)
  4. Review bitcoin-tribe source code (compare approaches)

🔑 Key Concepts

The Problem

React Native doesn't provide UDP socket access, which is required by HyperDHT for peer discovery and NAT traversal.

The Solution

Bare Kit provides a native runtime (worklet) that runs alongside React Native with full Node.js compatibility, including UDP socket access.

The Architecture

┌────────────────────┐
│  React Native      │  ← Your UI/UX layer
│  (Hermes/JSC)      │
└─────────┬──────────┘
          │
          │ IPC/RPC (bare-rpc)
          │
┌─────────▼──────────┐
│  Bare Worklet      │  ← Hyperswarm runs here
│  (Native Runtime)  │  ← Has UDP access!
│  ✅ Node.js APIs   │
│  ✅ UDP Sockets    │
│  ✅ Hyperswarm     │
└────────────────────┘

The Trade-offs

  • Pros: True P2P, no backend needed, full Hyperswarm functionality
  • ⚠️ Cons: Larger bundle (~238 MB), more complexity, newer technology

📖 Related Documentation


🚀 Implementation Status

Current Status: Documentation complete, ready for implementation

Next Steps:

  1. Review all documents in this folder
  2. Install dependencies (see IMPLEMENTATION_GUIDE_BARE_KIT.md)
  3. Create worklet and manager files
  4. Test on iOS and Android

💡 Quick Start

Want to get started right now?

# 1. Read the quick summary
open BARE_KIT_SUMMARY.md

# 2. Follow the production-ready implementation guide
open IMPLEMENTATION_GUIDE.md

# 3. Install dependencies
yarn add react-native-bare-kit@0.5.6 bare-rpc@0.2.5 hyperswarm@4.11.7 b4a@1.6.7 buffer@6.0.3

📊 Documentation Stats

Document Size Type Audience
WHY_HYPERDHT_NOT_IN_REACT_NATIVE.md 13 KB Analysis Everyone
BARE_KIT_SUMMARY.md 3 KB Reference Quick learners
BARE_KIT_SOLUTION.md 22 KB Technical Architects
IMPLEMENTATION_GUIDE.md ⭐⭐ 25 KB Implementation Developers
Total 63 KB Suite All roles

🎓 Learning Outcomes

After reading these documents, you'll understand:

✅ Why Hyperswarm doesn't work in standard React Native
✅ How Bare Kit provides a native runtime solution
✅ The architecture of dual-runtime React Native apps
✅ How to implement IPC/RPC communication
✅ Step-by-step implementation process
✅ Trade-offs and when to use this approach


🔗 External Resources


This documentation was created on October 6, 2025, based on analysis of the bitcoin-tribe project's successful implementation of Hyperswarm in React Native using Bare Kit.