> For the complete documentation index, see [llms.txt](https://skyslit.gitbook.io/magicjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://skyslit.gitbook.io/magicjs/api-references/backend/io.md).

# io()&#x20;

This function enables real-time, bidirectional communication between web clients and servers commonly used for features like real-time chat, live updates and collaborative editing in web applications.

> Example:

```typescript
import { createBackendFunction, io } from "@magicjs.dev/backend";
import moment from "moment";

export default createBackendFunction(async function () {
    try {
        io().to(`public/room`).emit(`refresh`);
    } catch (error) {}
});
```

When the backend function is invoked, potentially in response to an API request, it emits a "refresh" event to all clients within the "public/room" using the `io` module. This event can be intercepted on the client side, enabling real-time communication and supporting actions such as triggering a refresh or update on the client interface. This mechanism serves as a means to broadcast information to all connected clients in the specified room, fostering synchronized updates across multiple users in a real-time manner.

[Click here to refer GitHub.](https://github.com/skyslit/magicjs.dev/blob/main/packages/backend/src/index.tsx#L467)
