Logo of AppSignal

Menu
Documentation navigation

Installing AppSignal for JavaScript

First, add the @appsignal/javascript package to your package.json. Then, run yarn install/npm install. You'll also need a Push API key from the "Push and deploy" section of your App settings page.

You can also add these packages to your package.json on the command line:

1
2
yarn add @appsignal/javascript
npm install --save @appsignal/javascript

You can then import and use the package in your bundle:

1
2
3
4
5
6
import Appsignal from "@appsignal/javascript" // For ES Module
const Appsignal = require("@appsignal/javascript").default // For CommonJS module

const appsignal = new Appsignal({ 
  key: "YOUR FRONTEND API KEY"
})

It’s recommended (although not necessarily required) to use the instance of the Appsignal object like a singleton. One way that you can do this is by exporting an instance of the library from a .js/.ts file somewhere in your project.

1
2
3
4
5
import Appsignal from "@appsignal/javascript"

export default new Appsignal({
  key: "YOUR FRONTEND API KEY"
})

Currently, we have no plans to supply a CDN-hosted version of this library.

Supported browsers

This package can be used in any ECMAScript 5 compatible browser. We aim for compatibility down to Internet Explorer 9 (roughly 0.22% of all browsers used today). All browsers older than this can only supported on a “best effort” basis, and full functionality cannot be guaranteed.

When developing, don’t forget to check browser support on Can I Use? and the ES6 Compatibility Table, and provide the appropriate polyfills or fallbacks. In a small percentage of browsers, a Promise polyfill may be required to use this library.

We'd like to set cookies, read why.