rmnr
DocsTourSlicesBest PracticeAgentsInstall

Command Palette

Search for a command to run...

New

Slice · AI prompt

BroadcastChannel — Cross-tab Sync

Same-origin cross-tab + cross-iframe state sync via BroadcastChannel API. Tiny, no backend, no install.

Resource detail View source
Copy this prompt into Claude / Codex / Cursor
broadcast-channel-sync.prompt.mdmarkdown
# Install `broadcast-channel-sync` — BroadcastChannel — Cross-tab Sync

> Same-origin cross-tab + cross-iframe state sync via BroadcastChannel API.

📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail   : https://resource.rahmanef.com/slices/broadcast-channel-sync
🧠 JSON catalog   : https://resource.rahmanef.com/api/knowledge?slice=broadcast-channel-sync
🔗 Source         : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/broadcast-channel-sync

## 1. Install

```bash
// no install — Web Platform API
# alias: npx rr add broadcast-channel-sync
```

The CLI copies `frontend/slices/broadcast-channel-sync/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.

## 3. Wire it up

Run `npx rr add broadcast-channel-sync`. Use BroadcastChannel only for demo / cross-iframe state mirroring. Production data still goes through Convex realtime. Use the useBroadcastSync(channelName, initial) hook from @/features/broadcast-channel-sync.

## Rules of engagement

- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice

The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.