Skip to Content

Rollbar and React Native

Posted on One min read

If you’re having problems using the alpha Rollbar React Native package in your React Native app, it’s still possible to use it without linking. I’ve been seeing issues where compiling after following the installation throws errors relating to missing crashreporter headers, so in order to work around, I’ve used the following:

npm install rollbar
import rollbar from 'rollbar/src/react-native/rollbar';
import { ROLLBAR_CLIENT_TOKEN, ROLLBAR_ENVIRONMENT } from '../constants';

export const Rollbar = new rollbar({
  accessToken: ROLLBAR_CLIENT_TOKEN,
  captureUncaught: true,
  payload: {
     environment: ROLLBAR_ENVIRONMENT
  }
});

Use it as normal:

import { Rollbar } from './Rollbar';

Rollbar.info('Some message', errorDetails);

Note that this will not catch crashing issues in the native part of the app, but if you’re having problems getting the RN package linked into your project, this is a simple way of routing around until we get a stable release.