smart-feedback
v0.1.1
Published
Lightweight loader for your feedback widget (injects widget.js and exposes open/close/mount)
Readme
retour-feedback
A tiny loader that injects your hosted feedback widget (widget.js) and exposes a simple API:
- open()
- close()
- mount(options)
- unmount()
Install
npm i retour-feedbackUsage (any JS app)
import { setupFeedback } from "retour-feedback";
const rf = await setupFeedback({
projectId: "PROJECT_ID",
apiBase: "https://your-app.com", // or http://localhost:3000 in dev
attrs: { label: "Feedback", color: "#4F46E5", variant: "solid", size: "md" }
});
document.getElementById("feedbackBtn").addEventListener("click", () => rf.open());HTML trigger button
<button id="feedbackBtn">Feedback</button>What it does
- Loads your existing widget script from
${apiBase}/widget.js - Passes data attributes like data-project-id, data-label, etc.
- Proxies to the global window.Feedback API your widget script defines
Notes
- Make sure your backend’s /api/feedback accepts projectId and allows the site origin (CORS).
- For frameworks (React/Vue/Angular), just call open() from any button handler after setup.
