Rollbar SDK for Typescript React applications | Support Level: Supported
How to configure @rollbar/react and Rollbar.js for Typescript React projects.
Rollbar.js is a peer dependency of @rollbar/react, and both must be installed.
To install with npm:
npm install rollbar @rollbar/reactTo install with yarn:
yarn add rollbar @rollbar/reactFor the quickest start to get up and running, wrap the Rollbar Provider component around your app and any existing providers.
The above config will configure and enable Rollbar, will detect and report uncaught exceptions and promise rejections, and will make the Rollbar interface available to all components wrapped in the Provider via a React Context.
The configuration object is used to initialize Rollbar.js inside the Provider. See the configuration reference for a description of all options.
Type definitions from Rollbar.js may be imported whenever they are needed.
If your project uses Error Boundaries, or you plan to add them, @rollbar/react provides an ErrorBoundary component that is already Rollbar enabled.
To learn more about React Error Boundaries, read here. To learn more about Rollbar Error Boundaries, read here.
The useRollbar hook can be used in any function component to access the Rollbar interface.
To learn more about Rollbar hooks, see the main @rollbar/react doc.
React Hooks are only available in React function components. To access Rollbar from class components, use the React Context initialized by the Rollbar Provider.
To learn more about using Rollbar in class components, see the main @rollbar/react doc.
For more information on rollbar.js, please see the docs here.
For help with importing or requiring Rollbar into your project with different Typescript compiler options, please see this document here
| Products | Platform | Documentation | Resources | Company | ||
| Error Monitoring | JavaScript | PHP | Docs Overview | Blog | About Us | |
| Session Replay | Ruby | Python | Getting Started | Guides | Careers | |
| Pricing | iOS | Java | Notifications | Contact Us | ||
| Languages | .NET | Angular | Deploy Tracking | Changelog | ||
| Integrations | React | Laravel | Telemetry | |||
| Node | Rails | Security & Compliance | ||||
| Django | More... | API | ||||
| 2012-26 Rollbar Inc. Privacy Policy Terms of Service | ||||||