# receiver

Node.js-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/node/receiver/#api-Receiver) from a [`ReceivePacketFn`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/node/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 TCP socket data event, a `process.on('message', ...)` IPC handler, or a WebSocket message handler; 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 [`/node/sender`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/node/sender.md) on the other end and a protocol from [`/node/v3`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/node/v3.md) or [`/node/v4`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/node/v4.md); a channel from [`/node/channel`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/node/channel.md) creates both for you.

Function signatures match [`/browser/receiver`](https://www.hyperfrontend.dev/docs/libraries/network-protocol/browser/receiver.md) so cross-runtime communication is symmetric.

---

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