> For the complete documentation index, see [llms.txt](https://bugpilot.gitbook.io/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bugpilot.gitbook.io/api-docs/sdk-js/getting-started.md).

# Getting Started

## Overview

The [Bugpilot](https://www.bugpilot.io) SDK for JavaScript is an easy way to start bug reporting from your app front-end.

{% hint style="info" %}
If you are looking for a way to start screen recording, or collect bug reports, from your app back-end, from a server-side flow, check the [HTTP API](/api-docs/http-api/authentication.md) instead.
{% endhint %}

## Prerequisites

To get started with the SDK, you must follow these steps:

1. [Signup](https://dash.bugpilot.io/signup) for Bugpilot
2. [Install the Bugpilot tracking code](https://docs.bugpilot.io/en/articles/6389274-installing-the-bugpilot-script) to your web app
3. **Recommended.** Identify users

## Using the SDK

The SDK methods are available on the global Bugpilot object.&#x20;

#### Accessing the Bugpilot object

By default, the Bugpilot tracking code loads asynchronously, to minimize the impact on your pages performance. Before calling any SDK method, make sure the page has finished loading.

**For traditional apps:**&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```javascript
function doSomethingWithBugpilot() {
  window.Bugpilot.saveReport({
    source: "feedbackWidget",
    userProvidedDescription: `Feedback: ${feedback}`,
  });
}

window.addEventListener('load', doSomethingWithBugpilot);
if (document.readyState === 'complete') { doSomethingWithBugpilot(); }
```

{% endcode %}

**For Single-Page-Apps:**\
Call the SDK methods after your app has initialized and authenticated the users. You may also want to use the Optional Chaining operator to avoid throwing errors in case you call SDK methods while Bugpilot is not yet available:

```javascript
window.Bugpilot?.saveReport?.({
  source: "feedbackWidget",
  userProvidedDescription: `Feedback: ${feedback}`,
});
```

## SDK Methods

Here's what you can do with the SDK for JavaScript:

{% content-ref url="/pages/oZ44utzkKjDU1k3jPUaO" %}
[Saving Bug Reports](/api-docs/sdk-js/getting-started/saving-bug-reports.md)
{% endcontent-ref %}

## Need help?

Our team is always happy to chat with you! Talk to us using the chat widget in the bottom-right corner of your Bugpilot dashboard.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bugpilot.gitbook.io/api-docs/sdk-js/getting-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
