A lightweight, embeddable widget that lets a support agent highlight elements on a caller's page in real time.
- One script tag on the site
- Agent and user both use the same widget
- Peer-to-peer connection via PeerJS
- Only selector payload + hit/miss acknowledgments are sent
- Next.js app as a local demo surface
- Vanilla JS widget runtime in
src/ - PeerJS for WebRTC data channel setup
- esbuild for single-file widget bundling
- Bun for install, scripts, and local workflow
bun install
bun run devOpen two browser tabs to http://localhost:3000.
- In tab A, open the widget and click Create Session.
- Read the 6-character code to tab B.
- In tab B, click Join and enter the code.
- In tab A, click Arm Picker, then click any element on the page.
- Tab B should show a highlight. Tab A should receive hit or miss feedback.
bun run build:widgetGenerated files (not committed):
dist/support-highlight-widget.jsdist/support-highlight-widget.min.js
Use the minified bundle from your CDN:
<script src="https://your-cdn.example.com/support-highlight-widget.min.js" defer></script>The script auto-initializes and mounts a floating widget in the page corner.
- Agent -> User:
{ "type": "highlight-request", "payload": { selector, tagName, label, strategy } }
- User -> Agent:
{ "type": "ack", "result": "hit" | "miss" }
The widget exposes window.SupportHighlightDebug for manual testing.
Useful methods:
getState()createSession()joinSession(code)endSession()armPicker()/disarmPicker()highlight(payload)clearHighlight()
- If agent and user are on different pages, selectors may miss.
- Full page reloads break the active peer connection.
- Cross-origin iframe content cannot be targeted.