Hooks
useAutoResize and useThemeSync — the two hooks included in the WUI library that handle iframe height reporting and admin theme synchronization.
The WUI library ships two React hooks that handle iframe communication concerns your plugin should not have to manage manually.
useAutoResize
Automatically reports your plugin's content height to the admin host so the iframe resizes as your content grows or shrinks.
import { useAutoResize } from "./components/whatalo-ui";
function App() {
useAutoResize();
// Remaining plugin content — no other action needed
return <Page>...</Page>;
}How it works:
- Attaches a
ResizeObservertodocument.body - On each size change, schedules a measurement via
requestAnimationFrame - Reads
document.documentElement.scrollHeightas the reported height - Only sends a resize message when the height delta exceeds 1px (prevents noise)
- Reports the height to the host via
bridge.resize()
This approach keeps resize traffic minimal while keeping the iframe height accurate.
useThemeSync
Ensures your plugin's color scheme matches the admin's current light or dark theme.
import { useThemeSync } from "./components/whatalo-ui";
function App() {
useThemeSync();
// Theme tokens are now active — use --wui-* variables in your CSS
return <Page>...</Page>;
}How it works:
- Checks the
?theme=URL query parameter first — useful for modal iframes where the bridge may not be available at render time - Falls back to
useWhataloContext().themefrom the App Bridge - Sets
document.documentElement.setAttribute("data-theme", theme), which activates the[data-theme="dark"]CSS block instyles.css
As long as your styles reference --wui-* tokens, theme switching is automatic.
Recommended root App setup
Call both hooks at the top of your root App component before rendering any pages:
import { useAutoResize, useThemeSync, Spinner } from "./components/whatalo-ui";
import { useAppBridge } from "@whatalo/plugin-sdk/bridge";
function App() {
// Set up iframe height reporting and theme synchronization
useAutoResize();
useThemeSync();
const { currentPage, isReady } = useAppBridge();
// Wait for the bridge handshake before rendering
if (!isReady) return <Spinner />;
// Route between plugin pages using the page slug from the manifest
switch (currentPage) {
case "settings":
return <SettingsPage />;
default:
return <DashboardPage />;
}
}Action Components
Interactive components that trigger user actions — Button, Link, and Accordion — with a full real-world example combining multiple components.
Billing Overview
Monetize your plugin by creating pricing plans. Merchants subscribe to your plans, and you earn revenue minus a platform commission.