Widget Installation
The BugSpark widget is a lightweight JavaScript snippet that adds a bug reporting button to your application.
Environment Variable
All installation methods below reference an environment variable for your project API key. Never hard-code your API key in source code.
Add this to your .env (or .env.local) file:
BUGSPARK_PROJECT_KEY=YOUR_API_KEYYou can find your project API key in the Dashboard under Project Settings.
Script Tag
The simplest way to add BugSpark. Paste this before the closing </body> tag:
<script
src="https://cdn.bugspark.dev/widget.js"
data-project-key="${BUGSPARK_PROJECT_KEY}"
data-position="bottom-right"
async
></script>For server-rendered pages, inject the environment variable at build time or via your templating engine.
The widget loads asynchronously and does not block page rendering.
NPM / React
Install the package:
npm install @bugspark/widgetInitialize in your app entry point:
import { BugSpark } from "@bugspark/widget";
BugSpark.init({
projectKey: process.env.BUGSPARK_PROJECT_KEY,
position: "bottom-right",
});For React apps, initialize inside a useEffect:
import { useEffect } from "react";
import { BugSpark } from "@bugspark/widget";
function App() {
useEffect(() => {
BugSpark.init({
projectKey: process.env.BUGSPARK_PROJECT_KEY,
position: "bottom-right",
});
}, []);
return <div>{/* your app */}</div>;
}Vue
<script setup>
import { onMounted } from "vue";
import { BugSpark } from "@bugspark/widget";
onMounted(() => {
BugSpark.init({
projectKey: import.meta.env.VITE_BUGSPARK_PROJECT_KEY,
position: "bottom-right",
});
});
</script>Vue (Vite) requires the
VITE_prefix for client-side environment variables. AddVITE_BUGSPARK_PROJECT_KEYto your.envfile.
Angular
import { Component, OnInit } from "@angular/core";
import { BugSpark } from "@bugspark/widget";
import { environment } from "../environments/environment";
@Component({ selector: "app-root", template: "<router-outlet />" })
export class AppComponent implements OnInit {
ngOnInit() {
BugSpark.init({
projectKey: environment.bugsparkProjectKey,
position: "bottom-right",
});
}
}Add
bugsparkProjectKeyto yourenvironment.tsandenvironment.prod.tsfiles.
Verifying Installation
Once installed, you should see a small bug icon in the corner of your page. Click it to open the report form and submit a test report. Check the Dashboard to confirm the report arrived.