Vanilla JavaScript
Load the SDK
Section titled “Load the SDK”The BugFence server serves the standalone SDK at /sdk/bugfence.min.js. Replace the host with your deployment’s public origin:
<script src="https://bugs.example.com/sdk/bugfence.min.js" defer></script>Initialize the SDK after the script is ready:
<script> window.addEventListener('DOMContentLoaded', () => { BugFence.init({ projectKey: 'pk_live_your_public_key', endpoint: 'https://bugs.example.com/api/v1/reports', position: 'bottom-right', lazyWidget: true }); });</script>projectKey is a public ingestion key. Do not put secret or admin credentials in HTML or JavaScript. Set the production endpoint explicitly; the default points to localhost.
Use a custom trigger
Section titled “Use a custom trigger”<button id="report-problem" type="button">Report a problem</button><script> document.getElementById('report-problem').addEventListener('click', () => { if (BugFence.isRouteAllowed()) BugFence.open(); });</script>Vue, Angular, and Svelte
Section titled “Vue, Angular, and Svelte”The standalone script works in any browser framework. Load it in the browser and call BugFence.init() from the framework’s client-only lifecycle or application bootstrap. For server-rendered frameworks, do not access window or initialize the SDK during server rendering.
lazyWidget: true defers widget construction and mounting; it does not split or reduce the downloaded SDK bundle. See configuration.