客户端库

用 HTML 实现实时 WebSocket

在任何网页加一行 script 标签:立即获得已连接的客户端,以及实时在线人数、消息列表和弹出通知,无需构建流程。

登录后,示例代码会自动填入您的集群主机。 登录

使用 AI 编程智能体? 复制 Agent 提示词 ↓

  1. 加入 script 标签

    <!-- Before </body>, on every page that needs live updates -->
    <script src="https://hibira.io/embed/v1.js" data-key="YOUR_APP_KEY" data-host="ws.hibira.io" async></script>
  2. 放入现成的小组件

    <!-- People on this page right now (turn on "Send subscriber counts" in the app settings) -->
    <span data-hibira-online="lobby">0</span> online
    
    <!-- The newest "update" events on the news channel, newest first -->
    <ul data-hibira-feed="news" data-event="update" data-limit="10"></ul>
    
    <!-- A toast for each "alert" event: { "title": "...", "body": "...", "url": "..." } -->
    <div data-hibira-toast="alerts" data-event="alert" data-position="bottom-right"></div>
  3. 在自己的代码中使用客户端

    // Runs as soon as the script has loaded, even if this code runs first.
    (window.Hibira = window.Hibira || []).push((client) => {
      client.subscribe('orders').bind('order-shipped', (data) => {
        console.log('Order shipped', data);
      });
    });

Agent 提示词

将这段提示词粘贴到 Claude Code、Cursor、GitHub Copilot 或其他 AI 编程智能体,它会按照上方的设置,把 Hibira 接入您的 HTML 项目。

请将 YOUR_APP_KEY 等占位符替换为控制台中的值,或让智能体保留为环境变量,之后再自行填写。

或连接 Hibira MCP 服务器,让代理自行创建应用并填入凭据。 连接您的 AI 编程代理 →

请使用控制台中的应用密钥(key 与 secret)。频道、事件与授权端点的用法与 Pusher 完全相同。 库参考文档 ↗