# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://skyslit.gitbook.io/magicjs/api-references/backend/io.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
