1. Home
  2. Docs
  3. Bugfender SDK for web applications
  4. Installing the SDK

Installing the SDK

The SDK can be installed as a <script> tag that you can add to your HTML for simpler apps or as an NPM module that you can import for more complex web applications.

Install as NPM module

First of all, install SDK NPM package:

npm install @bugfender/sdk

Then you can init and use the SDK:

// Import Bugfender
import { Bugfender } from '@bugfender/sdk';

// Initialize. `appKey` is the only required option.
Bugfender.init({
    appKey: '<YOUR_APP_KEY_HERE>',
    // apiURL: 'https://api.bugfender.com',
    // baseURL: 'https://dashboard.bugfender.com',
    // overrideConsoleMethods: true,
    // printToConsole: true,
    // registerErrorHandler: true,
    // version: '',
    // build: '',
});

// Bugfender now can be used
Bugfender.log('Hello world!');

Remember to change <YOUR_APP_KEY_HERE> with the app key of your app. You can get an app key by signing up to Bugfender. For all the available options see our reference.

TypeScript

If you are writting an app using TypeScript, Bugfender includes a TypeScript definition file.

Install as an HTML tag

If you plan to use the SDK directly on your HTML/JS web page, you can import the SDK following these steps:

  • Get an app key at bugfender.com
  • Import Bugfender SDK JavaScript file
  • Init and use on your script
<script defer src="https://js.bugfender.com/bugfender.js"></script>
<script defer src="your-script.js"></script>

Note that to respect the loading order the script tags must have the defer attribute and not async. If async is used, the order is not guaranteed so there might be logs & errors from your app that Bugfender won’t catch.

// your-script.js
// Bugfender will be registered in `window`
// Initialize. `appKey` is the only required option.
Bugfender.init({
    appKey: '<YOUR_APP_KEY_HERE>',
});

// Bugfender now can be used
Bugfender.log('Hello world!');

Remember to change <YOUR_APP_KEY_HERE> with the app key of your app. For all the available options see our reference.