ยซ Back to blog posts

Firebase Crashlytics for React Native

Firebase Crashlytics for React Native

As we announced earlier in the year we're hard at work bring you a new and better Firebase experience for React Native. In this blog post we'll briefly cover 'what is Firebase Crashlytics', how you can get setup and what's new for the latest release of React Native Firebase Crashlytics.

What is Firebase Crashlytics?

Firebase Crashlytics is a lightweight easy to use realtime crash reporter that helps you track bugs, crashes and stability issues with your apps. With React Native this includes capturing JavaScript stack traces, unhandled promise rejections and native Android & iOS exceptions.

You can learn more about Firebase Crashlytics on the Firebase docs.

Getting started for React Native

Firebase Crahlytics for Android and iOS requires a Firebase project, you can create one via the Firebase console.

yarn add @react-native-firebase/[email protected]
react-native link @react-native-firebase/app
yarn add @react-native-firebase/[email protected]
react-native link @react-native-firebase/crashlytics

Once installed and linked; please follow the 'Add Firebase to your Project' guides on the Firebase website to download and install your Firebase project credentials into your app:

  1. Android
  2. iOS
  • Import the package into your JavaScript bundle
import '@react-native-firebase/crashlytics';

And that's it; application crashes and JavaScript exceptions are now automatically captured. You can also capture custom JavaScript errors as well as add custom logs and attributes that will be visible on any subsequent crash reports .

Here's a quick example:

import { firebase } from '@react-native-firebase/crashlytics';

await firebase.crashlytics().setAttributes({ something: 'something' });
firebase.crashlytics().log('A woopsie is incoming :(');
firebase.crashlytics().recordError(new Error('I did a woopsie'));

To see the full API please see our reference documentation.

New Features

React Native Firebase version v6.0.0 brings a host of new features for many Firebase services. Here's the one's we're most excited about for Firebase Crashlytics:

  • ๐Ÿ†• JavaScript stack traces are now automatically captured and visible on the Firebase Crashlytics console. We know you were excited about this when we announced it.
  • ๐Ÿ†• Optionally toggle automatic reporting of JavaScript unhandled Promise rejections to have them visible on the Firebase Crashlytics console.
  • ๐Ÿ†• Android Firebase Crashlytics NDK support by default - for capturing NDK related crashes, e.g. Yoga.
  • ๐Ÿ†• Added support for setting user identifiers as part of your crashes via setUserName & setUserEmail.

These are just a few highlights from the v6.0.0 Firebase Crashlytics for React Native release. For the full list of changes please visit the changelog.

---------------

We hope you'll love the new release for React Native Firebase Crashlytics and we're excited to share with you more updates on other Firebase services in React Native over the course of the next few weeks.

Please get in touch via GitHub, Twitter or Discord if you have any issues or questions. If you'd like to follow along with other modules and their status for v6.0.0 you can do so on this GitHub issue.

With ๐Ÿ’› from the React Native Firebase team at Invertase.


Share this blog post: