Shareit CLI is a local network file transfer tool for Node.js. It helps you send a file or folder from one machine to another on the same Wi-Fi or LAN.
- The sender resolves the input path and checks file system metadata.
- If the input is a directory, the sender creates a temporary ZIP archive in the OS temp directory using
archiver. - The sender starts an HTTP server on
0.0.0.0:5000with two endpoints:GET /metareturns JSON metadata (name,size,mtimeMs).GET /downloadstreams file bytes and supports HTTP range requests.
- The sender opens a UDP socket and broadcasts discovery packets every 2 seconds on port
41234.- Packet format:
FILE_SERVER:<sender-ip>:5000. - Broadcast target:
255.255.255.255:41234.
- Packet format:
- The receiver binds to UDP
41234, waits for the first valid discovery packet, then stops listening. - The receiver fetches
/metaand prepares a unique local output name to avoid overwrite collisions. - The receiver downloads from
/downloadusing streamed HTTP responses.- On interruption, it retries up to 5 times.
- If partial data exists, it sends
Range: bytes=<offset>-to resume. - If resume is not accepted by the sender, it restarts the transfer from byte 0.
- On completion, the receiver renames
<filename>.partto the final filename. - When a receiver connects to
/download, the sender stops UDP broadcasting. - On sender shutdown, temporary ZIP artifacts are removed.
- Node.js 18+
- Both devices must be on the same network
- Firewall must allow:
- UDP
41234 - TCP
5000
- UDP
npm installOptional global command for local development:
npm linkThen run with:
shareitWithout linking globally, run with:
node index.jsStart the app on both devices:
node index.jsYou will see a prompt:
Type <send> to send files and <recieve> to recieve files
- On the sender machine, type
send. - Enter a file path or folder path.
- Keep the sender process running.
- On the receiver machine, type
recieve. - Wait for discovery and download.
- The file is saved in the current working directory.
If a file with the same name already exists, a new name like name(1).ext is used.
- Current prompt keywords are
sendandrecieve. - Folder transfer is sent as a
.zipfile. - Temporary zip files are cleaned up when sender exits.