Parent window
Connecting…

Counter — Parent

postMessagewindowId
Shared counter
Either side calls INCREMENT_COUNTER on the other. Fire-and-forget — no return value.
Count0
Child window
Open a paired popup. Click the second button to increment the child's counter remotely.
Code
The whole flow on the parent side. The child mirrors it.
parent.tsx
import { useIwpcWindow } from '@silurus/iwpc';

const iwpc = useIwpcWindow();

// Register a procedure callers can invoke on this window.
useEffect(() => {
  iwpc?.register('INCREMENT_COUNTER', () => setCount((c) => c + 1));
  return () => iwpc?.unregister('INCREMENT_COUNTER');
}, [iwpc]);

// Open a child window and invoke its procedure remotely.
const child = await iwpc?.open('./child1', { width: 520, height: 540 });
child?.invoke('INCREMENT_COUNTER');