Skip to content

React ​

AdminVora is a DOM runtime, not a component library. It binds behaviour to the markup it finds — a table with data-av-datagrid becomes sortable, an element with data-av-chart mounts a chart. You write ordinary JSX with AdminVora's classes and hooks, and load the runtime from a <script> tag. There is no npm package to import and no wrapper components.

The react-vite starter kit is a working example:

bash
npm run create -- my-admin --kit=react-vite
cd my-admin
npm install
npm run dev        # http://localhost:5173

Load the assets ​

index.html holds the inline boot script, the stylesheet and the runtime. The kit copies the compiled bundle into public/assets/adminvora/.

html
<head>
  <!-- inline boot script first: sets theme attributes before first paint -->
  <link rel="stylesheet" href="/assets/adminvora/css/adminvora.min.css">
</head>
<body>
  <div id="root"></div>
  <script type="module" src="/src/main.jsx"></script>
  <script src="/assets/adminvora/js/adminvora.js" defer></script>
</body>

Keep the runtime after the module script. Deferred scripts run in document order, so React mounts first and the runtime's first scan sees a real page rather than an empty root.

Re-scan on every navigation ​

A client-side navigation replaces content behind the runtime's back, so announce each new view. AdminVora.init() re-scans and skips every element it already owns, so calling it after each navigation is safe.

js
// src/useAdminVora.js
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export function useAdminVora() {
  const { pathname } = useLocation();
  useEffect(() => {
    window.AdminVora?.init();
  }, [pathname]);
}

Call useAdminVora() once in your shell component. It is an effect, not a render-time call, because the scan has to see the committed DOM. Pass a subtree — AdminVora.init(el) — when you know exactly what changed.

Leave enhanced markup uncontrolled ​

The data grid owns row visibility; the validator owns input validity. Mirroring either in React state gives one element two owners, and you get a flicker or a value that snaps back. Render rows with .map() and let the runtime enhance them. Use defaultValue, not value, on enhanced fields.

Before React removes a subtree that holds vendor widgets (a chart, a rich-text editor), call AdminVora.destroy(el) to dispose them. It releases vendor instances and claims but does not detach listeners — see JavaScript Architecture.

Theming ​

Every theme decision is an attribute on <html>, changed at runtime through AdminVora.theme:

js
AdminVora.theme.set('preset', 'kuri');
AdminVora.theme.toggle();          // light ⇄ dark

No React state is involved and nothing re-renders; CSS custom properties do the work.

Listening to the runtime ​

js
useEffect(() => {
  const onChange = ({ key, value }) => console.log(key, value);
  AdminVora.on('av:theme:change', onChange);
}, []);

The full event list is in JavaScript Architecture.

Read next: Vue.

Documentation for @creativeigniter/adminvora