Skip to content
On this page


There is no fundamental difference between web sockets guards and regular HTTP application guards.

Binding guards

The following example uses a method-scoped guard. Just as with HTTP based applications, you can also use gateway-scoped guards (i.e., prefix the gateway class with a @UseGuards() decorator).

handleEvent(@WebSocket() socket: WebSocket) {
  socket.send({ topic: 'events', data: 'hello' })