Skip to content

Repository files navigation

LocalShare

LocalShare Logo

Zero-config peer-to-peer file sharing & messaging — no servers, no limits.

🚀 Live Demo · Report Bug · Request Feature

What is LocalShare?

LocalShare is a fully client-side, peer-to-peer file-sharing and messaging web application built with vanilla HTML, Tailwind CSS v4, and JavaScript. It leverages WebRTC via PeerJS to enable devices on the same network to discover each other and transfer files directly — no intermediary server, no file size limits, no data leaves your network.

✨ Features

Feature Description
Direct P2P Transfers Files stream device-to-device over encrypted WebRTC data channels
Zero-Config Discovery Devices sharing a public IP auto-discover each other via room registry
Corruption-Free Transfers FNV-1a checksum verification + ordered chunk assembly guarantees file integrity
High-Speed Chunking 256KB chunks with WebRTC backpressure control for maximum throughput
Failover Room Host Automatic host election with seamless failover if the host disconnects
Secure Handshakes Explicit Accept/Reject confirmation before any connection is established
Real-Time Transfer Metrics Live speed, percentage, and byte-count tracking with progress bars
Room Chat Encrypted in-room messaging between all connected peers
Manual Peer Connect Bridge any network via direct Peer ID or QR code scanning
Drag & Drop Native drag-and-drop file selection with multi-file support
Smart File Icons Automatic icon detection for 30+ file types (media, code, archives, apps)

🆕 v2.0 — What's New

Transfer Engine (Complete Rewrite)

  • Eliminated file corruption: Replaced naive FileReader chunking with direct ArrayBuffer slicing, ordered chunk indices, and FNV-1a checksum verification on receive
  • 256KB chunk size (up from 64KB) for 4× faster transfers
  • WebRTC backpressure: Monitors dataChannel.bufferedAmount to prevent buffer overflow and data loss
  • MIME type preservation: Files are reconstructed with their original MIME type for proper handling by the OS
  • Transfer-complete handshake: Receiver verifies chunk count and checksum before assembling the final Blob
  • Removed artificial delays: Replaced setTimeout(10ms) chunking with requestAnimationFrame for smooth, non-blocking sends

Discovery & Networking

  • Single-target failover architecture: Devices probe one unified room host ID; on collision, they silently fall back to client mode
  • Faster room resolution: Ipify lookup with 4s abort timeout and graceful local fallback
  • Clean console: Suppressed all expected PeerJS warnings during normal discovery flow
  • Reconnection handling: Automatic signaling server reconnect with visual status indicators

UI/UX Overhaul

  • Professional SaaS design: Clean card-based layout with Inter font, consistent spacing, and subtle glass effects
  • Toast notification system: Replaced basic popup with animated, typed toast messages (info/success/error/warning)
  • Drag-and-drop zone: Visual feedback with scale animation on drag-over
  • File type icons: 30+ file extensions mapped to Bootstrap Icons
  • Live transfer speed: Real-time MB/s display during sends and receives
  • Status indicators: Network dot, device status, and connection count badges
  • Responsive grid: 12-column layout that adapts from mobile to desktop
  • Dark-mode optimized: Pure black (#000) AMOLED background with cyan/mint accents

Name Generator

  • 48 adjectives × 48 nouns × 900 numbers × 16 emojis = 33M+ unique combinations
  • Emoji prefix for instant visual identification in peer lists

🚀 Getting Started

Live App

👉 https://local-share.netlify.app/

Local Setup

# Clone the repository
git clone https://github.com/Infinitode/LocalShare.git

# Navigate into the project
cd LocalShare

# Compile Tailwind CSS v4 (requires Node.js)
npx @tailwindcss/cli -i input.css -o output.css --watch

# Open index.html in your browser or use a local server
npx serve .

🏗️ Architecture

┌─────────────────────────────────────────────────────────┐
│                    Room Discovery                        │
│                                                         │
│  Device A ──┐                                          │
│  Device B ──┼──► Room Host (ls-roomhost-{room-id})    │
│  Device C ──┘       │                                   │
│                     ▼                                   │
│              Registry Roster Broadcast                   │
│              (peer list sync to all clients)             │
└─────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────┐
│                   File Transfer                          │
│                                                         │
│  Sender                      Receiver                   │
│  ──────                      ────────                   │
│  1. Read file as ArrayBuffer                            │
│  2. Compute FNV-1a checksum                             │
│  3. Send metadata (name, size,                          │
│     chunks, mime, checksum)                             │
│  4. Stream 256KB chunks ──────► Collect by index        │
│     (with backpressure)         5. Verify chunk count   │
│                                 6. Verify checksum      │
│                                 7. Assemble Blob        │
│                                 8. Offer download       │
└─────────────────────────────────────────────────────────┘

Room Assignment

LocalShare queries ipify for your public IP, hashes it into a deterministic #room-id. All devices behind the same NAT share this room.

Host Election

The first device binds to ls-roomhost-{room-id}. Subsequent devices detect the ID is taken and connect as clients. If the host drops, the next heartbeat triggers a new election.

Transfer Integrity

Every file transfer includes:

  1. Chunk sequencing — each chunk carries its index
  2. FNV-1a checksum — computed over the full file before send, verified after assembly
  3. MIME type — preserved for correct Blob construction
  4. Completion signal — explicit transfer-complete message triggers final verification

🛠️ Tech Stack

  • HTML5 — Semantic markup
  • Tailwind CSS v4 — Utility-first styling (compiled via @tailwindcss/cli)
  • Vanilla JavaScript (ES2022) — No frameworks, no build step for logic
  • PeerJS — WebRTC abstraction for data channels
  • QRCode.js — Instant QR code generation for peer IDs
  • Bootstrap Icons — Icon system

🤝 Contributing

Contributions make the open-source community an amazing place. Any contributions are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Or simply open an issue with bug reports or suggestions.

📄 License

LocalShare is released under the MIT License (Modified). See LICENSE for details.

Modified Clause: Derivative works must be clearly distinguished from the original and distributed under a different name.


Made with ❤️ by Infinitode

About

A minimal fully functional PeerToPeer web app built using vanilla HTML, CSS, and JS.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages