Official package · Frameworks

Realtime for react-admin: live lists, viewers and edit locks

Free and open source: lists and records update by themselves, you see who else has a record open, and only one person at a time can edit it. react-admin 5, React 18 and 19, any data provider.

npm versionLicense

Fastest way: one prompt with the Hibira plugin

Install the plugin in your AI coding agent and paste the prompt. The agent signs you in, creates a free app if you need one, writes the code and sends a test event. GitHub ↗

  1. Install the plugin

    claude plugin marketplace add hibira-io/agent-plugin
    claude plugin install hibira@hibira
  2. Paste this prompt

    Add Hibira react-admin (@hibira-io/react-admin) to this project.
    Follow https://hibira.io/guides/react-admin, adapted to how this project is already set up.
    If I have no Hibira app yet, create a Free one that allows http://localhost so I can test right away.
    Keep the app key and secret in environment variables, add placeholders to .env.example, and never commit real values or send the secret to a browser.
    When you are done, send a test event, show me it arriving, and list the files you changed.

Prefer to do it by hand? These are the steps below:

  1. Install
  2. Set it up
  3. Use it

Other AI tools and what the plugin includes →

  • <LiveRefresh /> refetches a list, its records and references when anyone changes them.
  • <RecordViewers /> shows who else has the record open, and <RecordLockGuard> keeps the form read-only while someone else edits, with no lock table.
  • <LiveRecord /> warns an editor when the record was saved or deleted elsewhere, and <NewRecordsBadge /> counts new records in the menu.
Two people open the same order in react-admin: the first can edit it, the second sees who is editing and gets a read-only form.
Two people open the same order in react-admin: the first can edit it, the second sees who is editing and gets a read-only form.

Sign in to see these snippets with your own cluster host. Sign in

  1. Install

    npm install @hibira-io/react-admin pusher-js
    # on your backend
    npm install pusher
  2. Set it up

    import { Admin, Edit, List, Resource, SimpleForm } from 'react-admin';
    import Pusher from 'pusher-js';
    import { addRealtimeMethods, LiveRecord, LiveRefresh, RecordLockGuard, RecordViewers } from '@hibira-io/react-admin';
    
    const pusher = new Pusher(import.meta.env.VITE_HIBIRA_KEY, {
      cluster: 'hkg',
      wsHost: 'ws.hibira.io',
      channelAuthorization: { endpoint: '/api/hibira/auth', transport: 'ajax' },
    });
    const realtime = addRealtimeMethods(dataProvider, pusher, { channelPrefix: 'private-' });
    
    const OrderList = () => <List><LiveRefresh />{/* ... */}</List>;
    const OrderEdit = () => (
      <Edit actions={<RecordViewers />}>
        <LiveRecord />
        <RecordLockGuard><SimpleForm>{/* ... */}</SimpleForm></RecordLockGuard>
      </Edit>
    );
    
    export const App = () => (
      <Admin dataProvider={realtime}>
        <Resource name="orders" list={OrderList} edit={OrderEdit} />
      </Admin>
    );
  3. Use it

    import Pusher from 'pusher';
    import { authorizeChannel, publishResourceEvent } from '@hibira-io/react-admin/server';
    
    const pusher = new Pusher({
      appId: process.env.HIBIRA_APP_ID!,
      key: process.env.HIBIRA_KEY!,
      secret: process.env.HIBIRA_SECRET!,
      host: 'ws.hibira.io',
      useTLS: true,
    });
    
    // POST /api/hibira/auth, after checking the session: signs private and presence channels
    authorizeChannel(pusher, socketId, channelName, { id: user.id, fullName: user.name });
    
    // after updating order 42
    await publishResourceEvent(pusher, { resource: 'orders', type: 'updated', ids: [42] }, { channelPrefix: 'private-', socketId: req.headers['x-socket-id'] });

Before you start

  • Private and presence channels need an auth endpoint on your backend that signs subscriptions with the app secret, as with pusher-js.
  • The edit lock goes to whoever opened the record first and passes on as soon as they leave. If presence is unavailable, nothing is locked.

Use the app key from your dashboard; the secret stays on your server. Channels, events and authorization endpoints work exactly as they do with Pusher. Create your free account →