stiano.dev / experiments

Phone transfer

Connect two phones and send messages and files straight from one to the other. Pair them with QR codes when they share a Wi-Fi or a hotspot, no internet needed, or with a code or link when you are online.

Nearby, no internet

Both phones on the same Wi-Fi, or one on the other’s hotspot. One shows a QR code, the other scans it and shows one back.

Online, by code or link

Anywhere with internet. One phone starts; the other types the code, opens the link or scans it.

How it works

The phones talk to each other over WebRTC, the same technology browsers use for video calls, here with just a data channel. To connect, each phone has to tell the other where it can be reached and how to check it’s really the other phone (an address, a password and a certificate fingerprint). Usually a server passes those between them.

Nearby, no internet: the QR codes do the server’s job. The first code holds the first phone’s details; the second phone scans it and answers with its own code. After that the phones connect straight across the local network, so it works on a Wi-Fi without internet, or with one phone on the other’s hotspot. Both phones need this page loaded once while online; after that it opens without internet too. Some networks (guest Wi-Fi, some offices) keep devices from seeing each other; then it can’t connect.

Online: a small room on this site’s server passes the details between the phones, and a STUN server helps them find each other through their routers. Most of the time they then connect directly. Where they can’t (some mobile networks), the files go through the room instead, which is slower.

Why not Bluetooth? Web Bluetooth only lets a page connect to a Bluetooth device such as a heart rate sensor. A web page can’t make the phone advertise itself as a device the other phone could connect to, so two phones can’t pair through the browser. Safari on iPhone has no Web Bluetooth at all.

Files go straight into the other phone’s memory and are never stored on a server. Very big files may not fit on an older phone.