---
title: Stimulus integration guide
description: Honeybadger monitors your Stimulus applications for errors and exceptions so that you can fix them wicked fast.
url: https://docs.honeybadger.io/lib/javascript/integration/stimulus/
---

**Typical installation time:** 5 minutes

Hi there! You’ve found Honeybadger’s guide to **Stimulus error and exception tracking**. Once installed, Honeybadger will automatically report errors from your Stimulus application.

## Installation

First, install *honeybadger.js*:

```plaintext
# npm
npm add @honeybadger-io/js --save


# yarn
yarn add @honeybadger-io/js
```

Then, configure Stimulus to report errors to Honeybadger:

```js
// In a Rails app this code typically resides in app/javascript/packs/application.js
// In a non-Rails app, usually src/application.js


// Import honeybadger.js
import { Application } from "stimulus";
import * as Honeybadger from "@honeybadger-io/js";


// Configure honeybadger.js
Honeybadger.configure({
  apiKey: "PROJECT_API_KEY",
  environment: "production",
  revision: "git SHA/project version",
});


// Start Stimulus application
const application = Application.start();


// Set up error handler
application.handleError = (error, message, detail) => {
  console.warn(message, detail);
  Honeybadger.notify(error);
};


// Perform your other Stimulus setup here
```

Note

Errors that happen in development and test environments are not reported by default. To always report errors or to change the defaults, see [Environments and Versions](https://docs.honeybadger.io/lib/javascript/errors/environments-and-versions/#development-environments).

## Reporting errors

Honeybadger also reports all uncaught exceptions outside of Stimulus controllers using our `window.onerror` handler. To disable uncaught error reporting:

```js
Honeybadger.configure({ enableUncaught: false });
```

You can also manually notify Honeybadger of errors and other events in your application code:

```javascript
try {
  // ...error producing code...
} catch (error) {
  Honeybadger.notify(error);
}
```

See the [Reporting Errors How-to Guide](https://docs.honeybadger.io/lib/javascript/errors/reporting-errors/) for more info.

## Identifying users

Honeybadger can track what users have encountered each error. To identify the current user in error reports, add a user identifier and/or email address with `Honeybadger.context`:

```javascript
Honeybadger.setContext({
  user_id: 123,
  user_email: "user@example.com",
});
```

## Tracking deploys

As with vanilla JavaScript applications, you can notify Honeybadger when you’ve deployed a new build. Honeybadger will associate an error report with a specific revision number (matching the ‘revision’ field in your *honeybadger.js* configuration).

Here’s a simple `curl` script to record a deployment:

```sh
HONEYBADGER_ENV="production" \
HONEYBADGER_REVISION="$(git rev-parse HEAD)" \
HONEYBADGER_REPOSITORY="$(git config --get remote.origin.url)" \
HONEYBADGER_API_KEY="Your project API key" \
  && curl -g "https://api.honeybadger.io/v1/deploys?deploy[environment]=$HONEYBADGER_ENV&deploy[local_username]=$USER&deploy[revision]=$HONEYBADGER_REVISION&deploy[repository]=$HONEYBADGER_REPOSITORY&api_key=$HONEYBADGER_API_KEY"
```

Be sure that the same revision is also configured in the *honeybadger.js* library. Read more about deploy tracking in the [API docs](https://docs.honeybadger.io/api/deployments).

### Tracking deploys from Netlify

If you are deploying your site to Netlify, you can notify Honeybadger of deployments via Netlify’s webhooks. Go to the **Deploy notifications** section of the **Build & deploy** tab for your site settings, and choose to add an Outgoing webhook notification. Choose `Deploy succeeded` as the event to listen for, and use this format for your URL:

`https://api.honeybadger.io/v1/deploys/netlify?api_key=YOUR_HONEYBADGER_API_KEY_HERE`

The environment that will be reported to Honeybadger defaults to the Netlify environment that was deployed, but you can override that with `&environment=CUSTOM_ENV` in the webhook URL, if you like.

## Source map support

Honeybadger can automatically un-minify your code if you provide a source map along with your minified JavaScript files. See our [Source Map Guide](https://docs.honeybadger.io/lib/javascript/errors/using-source-maps/) for details.

## Collect user feedback

When an error occurs, a form can be shown to gather feedback from your users. Read more about this feature [here](https://docs.honeybadger.io/lib/javascript/errors/collecting-user-feedback/).

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
