@appsignal/preact

Preact 10.0.0This integration requires Preact 10.0.0 or higher.

Installation

With npm or yarn

Add the @appsignal/preact and @appsignal/javascript packages to your package.json. Then, run npm install/yarn install.

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

yarn add @appsignal/javascript @appsignal/preact
npm install --save @appsignal/javascript @appsignal/preact

With JSPM.io import maps

Using the JSPM.io import map generator, you can generate an import map for your application's dependencies.

Add @appsignal/javascript and @appsignal/preact to the dependencies list in the generator, then add the generated import map and ES module shims to your application's code.

With rails-importmap

Use the following command to add these packages to your Rails application's import maps:

./bin/importmap pin @appsignal/javascript @appsignal/preact

Usage

Error Boundary

If you are using Preact v10.0.0 or higher, you can use the ErrorBoundary component to catch errors from anywhere in the child component tree.

import { Component } from "preact";
 
import { appsignal } from "./appsignal";
import { ErrorBoundary } from "@appsignal/preact";
 
const FallbackComponent = () => (
  <div>Uh oh! There was an error :(</div>
);
 
export default class App extends Component {
  render() {
    return (
      <ErrorBoundary
        instance={appsignal}
        tags={{ tag: "value" }} {/* Optional */}
        fallback={(error) => <FallbackComponent />} {/* Optional */}
      >
        { /** Child components here **/}
      </ErrorBoundary>
    )
  }
}

Need more help?

Contact us and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.

Contact us

Start a trial - 30 days free

AppSignal is a great way to monitor your Ruby, Elixir & Node.js applications. Works great with Rails, Phoenix, Express and other frameworks, with support for background jobs too. Let's improve your apps together.

Start a trial