Skip to content

Cloud vs LAN mode

PairKit has two transports. They behave identically from your game code’s perspective; the difference is where the WebSocket router lives.

Cloud mode (default)

Unity connects to wss://relay.pairkit.dev — a hosted relay running on Fly.io. Phones reach it over the public internet. You don’t run any infrastructure.

Use Cloud mode when:

  • Players are remote (different cities, different networks).
  • You’re prototyping and don’t want to think about networking.
  • You’re building a streaming setup, kiosk, or any deployment where the host has reliable internet.

Trade-offs:

  • Requires internet on both Unity’s side and every phone’s side.
  • Latency is network round-trip — typically 50-200 ms depending on geography.
  • The hosted relay is shared infrastructure with rate limits and a 4-hour session TTL.

LAN mode

Unity runs the relay in-process. The Unity build opens a local HTTP+WebSocket port and serves the web controller bundle directly to phones on the same Wi-Fi network.

Use LAN mode when:

  • You’re at an in-person event (LAN party, conference booth, live show).
  • Internet is unreliable or unavailable.
  • You want sub-5ms latency for fast-paced games.
  • You don’t want to depend on (or pay for) hosted infrastructure.

Trade-offs:

  • Phones must be on the same Wi-Fi as the host machine. Cellular phones can’t reach a LAN address.
  • Some Wi-Fi networks (corporate, guest, hotel) block client-to-client traffic (“AP isolation”); LAN mode fails on those.
  • WebGL builds cannot host a LAN relay (browsers can’t open listening sockets). Use Cloud for WebGL.

See the LAN mode page for the full setup, firewall guidance, and troubleshooting.

Why isn’t there a “Hybrid” mode?

A combined session that auto-upgrades same-Wi-Fi phones to LAN while still serving remote players over Cloud is theoretically attractive. The optimization saves the LAN players ~50-100 ms.

It’s not implemented because browsers block it. A Cloud session is served over HTTPS (wss://relay.pairkit.dev); for a phone on the same Wi-Fi to connect to a private-IP relay, the HTTPS page would need to open a ws:// connection to a non-public address. Browsers refuse this as mixed content, and the Local Network Access spec that would unblock it isn’t broadly shipped yet.

When Local Network Access lands across iOS Safari, Android Chrome, and desktop browsers, Hybrid becomes worth building. Until then, pick the mode that fits your audience: Cloud for remote, LAN for in-person.

Decision shortcut

SituationMode
Building anything for the open internetCloud
Streaming setup, public-facing demoCloud
Conference booth, live event, LAN partyLAN
WebGL build of any kindCloud (LAN doesn’t support WebGL)
Prototyping at your deskEither; Cloud is one less knob
Latency-sensitive (rhythm games, fighting games)LAN if you can require same Wi-Fi

Switch the mode via the Relay Mode dropdown on PhoneControllerManager. The rest of your game code doesn’t change.

Next