Svelte app example
Quick installation guide to setup the BetterBugs feedback widget for your Svelte applications.
How to Install BetterBugs Feedback Widget in Svelte apps
Here are the steps for it:
Initialize the Widget (with default UI)
Use the following initialization code in your Svelte app’s component. Don’t forget to add your Workspace API Key and Project ID in the function:
<script>
// BetterBugs SDK Initialization Code
import { onMount, onDestroy } from 'svelte';
let bbInstance = null;
onMount(async () => {
if (typeof window !== 'undefined') {
const { default: Betterbugs } = await import('@betterbugs/web-sdk');
bbInstance = new Betterbugs({
apiKey: "YOUR_API_KEY_HERE", // Workspace API key
projectId: "YOUR_PROJECT_ID_KEY_HERE", // Project to report bugs to
});
}
});
onDestroy(() => {
bbInstance?.destroy?.();
});
</script>
<h1>BetterBugs Web SDK Widget | Svelte</h1>Customize the Widget UI (Optional)
You can customize the widget with your brand colors and design from the initialization function:
<script>
// BetterBugs SDK Initialization Code
import { onMount, onDestroy } from 'svelte';
let bbInstance = null;
onMount(async () => {
if (typeof window !== 'undefined') {
const { default: Betterbugs } = await import('@betterbugs/web-sdk');
bbInstance = new Betterbugs({
apiKey: "YOUR_API_KEY_HERE", // Workspace API key
projectId: "YOUR_PROJECT_ID_KEY_HERE", // Project to report bugs to
// UI Customization Examples
position: {
top: "30px",
right: "20px",
},
styles: {
primaryColor: "#e41c38",
primaryTextColor: "#fff",
theme: "light",
},
});
}
});
onDestroy(() => {
bbInstance?.destroy?.();
});
</script>
<h1>BetterBugs Web SDK Widget | Svelte</h1>The feedback widget should be available at the bottom right side of your app screen (with the default UI).
NOTE: If the widget is not visible,
Please check if you’ve correctly entered the API key and Project ID.
Check for the console errors, if any.
If you’re still stuck, try running your dev server in the INCOGNITO mode of your web browser.
Some ad blockers or extensions may also prevent the Widget from running. Please turn them off and try running the application again. It should work fine.
You're good to go.
Last updated