---
title: "raknet.add_send_hook"
description: "Registers a callback for outgoing native sends."
---

```lua
raknet.add_send_hook(callback: (RakNetPacket) -> ()): ()
```

---

## Aliases

None.

---

## Arguments

<ParamField body="callback" type="(RakNetPacket) -> ()" required>
  The callback to register. Keep the same function object for removal.
</ParamField>

---

## Returns

This function returns no values.

Callback return values are discarded. Packet userdata is only valid synchronously during the callback: copy bytes, never retain packet or yield. Library registration does not prove the native hook was installed.

**Related types:** [RakNet types & behavior](/reference/raknet/types).

---

## Example

```lua
local function observe(packet)
    print(packet.PacketId, packet.Size)
    local bytes = packet.AsString
    print(#bytes)
end
raknet.add_send_hook(observe)
task.delay(5, function() raknet.remove_send_hook(observe) end)
```
