> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# onEvent

> Register a low-level observer for every inbound RELAY event.

[on-call]: /docs/server-sdks/reference/typescript/relay/client/on-call

[on-message]: /docs/server-sdks/reference/typescript/relay/client/on-message

Register a low-level callback that fires for every inbound `signalwire.event`,
regardless of type. This is a generic escape hatch that runs **before** the
typed [`onCall()`][on-call] / [`onMessage()`][on-message] routing.

Most applications should use the typed [`onCall()`][on-call] and
[`onMessage()`][on-message] handlers instead. Use `onEvent()` only when you need
to observe raw events the typed handlers don't cover.

## **Parameters**

Callback fired for every inbound event. Receives the event type and its raw
params. May be async. Errors thrown here are logged but never tear down the
dispatcher.

## **Returns**

The same handler, returned to support decorator-style usage.

## **Example**

```typescript {9}
import { RelayClient } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_API_TOKEN!,
  contexts: ['default'],
});

client.onEvent((eventType, params) => {
  console.log(`Event: ${eventType}`, params);
});

await client.run();
```