brily-nps
v0.1.0
Published
Framework-agnostic NPS widget loader for Brily. One mount() call drops the floating feedback bubble into any page (vanilla JS, Vue, Svelte, Solid, etc.).
Maintainers
Readme
brily-nps
Framework-agnostic loader for the Brily NPS widget. Works in vanilla JS, Vue, Svelte, Solid, Angular — anything that isn't React (for React use brily-nps-react).
≈ 1 KB gzipped, no dependencies.
Install
npm i brily-npsOr via script tag:
<script src="https://unpkg.com/brily-nps" defer></script>
<script>
BrilyNps.mount({ surveyKey: 'sk_nps_...' });
</script>Usage
import { mount, show, setCustomer } from 'brily-nps';
// On app boot:
mount({
surveyKey: 'sk_nps_xxxxxxxx',
customerId: user.id,
customerEmail: user.email,
metadata: { plan: 'pro' },
});
// Optional — force-open the bubble from a "Give feedback" button:
document.querySelector('#feedback-btn')?.addEventListener('click', show);
// After a SPA login / logout, update identity without reloading:
setCustomer(newUser.id, newUser.email);API
| Function | Purpose |
|----------|---------|
| mount(options) | Load the widget script once. Re-calling with the same surveyKey just updates identity. |
| show() | Open the bubble / card immediately. Cadence de-dup still applies. |
| reset() | Clear the local "already shown" flag so the next mount() call re-shows the widget. |
| setCustomer(id, email?, metadata?) | Update the identity attached to future responses. |
Options
| Option | Type | Required | Notes |
|--------|------|----------|-------|
| surveyKey | string | ✓ | Starts with sk_nps_ — find it at https://dashboard.brily.app/nps |
| customerId | string | | Your internal user id (max 120 chars) |
| customerEmail | string | | For detractor follow-up + dashboard display |
| metadata | Record<string, unknown> | | Arbitrary JSON attached to every response |
| autoOpen | boolean | | Open the bubble on mount instead of lazy |
| host | string | | Self-hosted / staging override |
License
MIT
