Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference {% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %} # @firebase/crashlytics/react-router ## Functions | Function | Description | | --- | --- | | [CrashlyticsRoutes({ firebaseApp, crashlyticsOptions, children, ...props }, input)](./crashlytics_react-router.md#crashlyticsroutes_db8200c) | (Public Preview) A wrapper around Routes from react-router-dom that automatically captures errors in route components.This component acts as a replacement for Routes from react-router-dom. It wraps the routes in an error boundary that captures errors thrown during rendering and reports them to Crashlytics. The error boundary is reset on navigation (path changes). | ## Interfaces | Interface | Description | | --- | --- | | [Crashlytics](./crashlytics_react-router.crashlytics.md#crashlytics_interface) | (Public Preview) An instance of the Firebase Crashlytics SDK.Do not create this instance directly. Instead, use [getCrashlytics()](./crashlytics.md#getcrashlytics_a9d22a1). | | [CrashlyticsFeature](./crashlytics_react-router.crashlyticsfeature.md#crashlyticsfeature_interface) | (EXPERIMENTAL) An opaque feature plugin object returned by Crashlytics feature factory functions such as [breadcrumbs()](./crashlytics.md#breadcrumbs). | | [CrashlyticsOptions](./crashlytics_react-router.crashlyticsoptions.md#crashlyticsoptions_interface) | (Public Preview) Options for initializing the Crashlytics service using [getCrashlytics()](./crashlytics.md#getcrashlytics_a9d22a1). | ## function({ firebaseApp, crashlyticsOptions, children, ...props }, ...) ### CrashlyticsRoutes({ firebaseApp, crashlyticsOptions, children, ...props }, input) {:#crashlyticsroutes_db8200c} > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. > A wrapper around `Routes` from `react-router-dom` that automatically captures errors in route components. This component acts as a replacement for `Routes` from `react-router-dom`. It wraps the routes in an error boundary that captures errors thrown during rendering and reports them to Crashlytics. The error boundary is reset on navigation (path changes). Signature: ```typescript export declare function CrashlyticsRoutes(input: RoutesProps & { firebaseApp: FirebaseApp; crashlyticsOptions?: CrashlyticsOptions; }): React.ReactElement | null; ``` #### Parameters | Parameter | Type | Description | | --- | --- | --- | | { firebaseApp, crashlyticsOptions, children, ...props } | (not declared) | | | input | RoutesProps & { firebaseApp: [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface); crashlyticsOptions?: [CrashlyticsOptions](./crashlytics_react-router.crashlyticsoptions.md#crashlyticsoptions_interface); } | | Returns: React.ReactElement \| null The rendered routes wrapped in an error boundary. ### Example ```tsx import { useEffect, useState } from "react"; import { CrashlyticsRoutes } from "firebase/crashlytics/react-router"; import { FirebaseApp, initializeApp } from "firebase/app"; export default function MyApp() { const [app, setApp] = useState(null); useEffect(() => { if (getApps().length === 0) { const newApp = initializeApp({...}); setApp(newApp); } else { setApp(getApp()); } }, []); return ( <> {app && ( } /> } /> )} ... ); } ```