# receiver

Browser-side inbound pipeline: frames in, opened packets out.

`createReceiver(label, receivePacket, logger, open, onDrop?)` builds a [`Receiver`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/receiver/#api-Receiver) from a [`ReceivePacketFn`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/receiver/#api-ReceivePacketFn) callback that takes each opened [`UnencryptedPacket`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-UnencryptedPacket) and the session's [`PacketOpener`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-PacketOpener) ([`protocol.open`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-Protocol-prop-open)). `receiver.receive(frame)` takes the raw bytes from a [`message`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-Data-prop-message) event on `window`, a `MessagePort`, or a `Worker`; a single open queue opens one frame at a time, which keeps the session's replay counter exact, and delivers each packet in order. A frame that is forged, replayed, malformed, or from another session is reported through [`onDrop`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-ChannelOptions-prop-onDrop) and never delivered.

Hello frames belong to the protocol's [`acceptHello`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/#api-HelloExchange), not to the receiver. Pair with [`/browser/sender`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/sender.md) on the other end and a protocol from [`/browser/v3`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/v3.md) or [`/browser/v4`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/v4.md); a channel from [`/browser/channel`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/channel.md) creates both for you.

---

Canonical page: https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/receiver/
This file: https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/receiver.md
Documentation index: https://www.hyperfrontend.dev/llms.txt
