# @firebase/crashlytics

> The Firebase Web Telemetry package of the Firebase JS SDK

Latest version **0.1.0** (published 2026-11-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @firebase/crashlytics
pnpm add @firebase/crashlytics
yarn add @firebase/crashlytics
bun add @firebase/crashlytics
```

Provides the command `crashlytics-setconstants`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2026-11-02 |
| First published | 2026-05-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 21 |
| Unpacked size | 2.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5154 |
| Author | Firebase |
| Maintainers | firebase-ops, feiyang.chen, google-wombot, chholland, lahirumaramba.google, ajp.google |

## Links

- npm: https://www.npmjs.com/package/@firebase/crashlytics
- Repository: https://github.com/firebase/firebase-js-sdk
- Homepage: https://github.com/firebase/firebase-js-sdk#readme
- Issues: https://github.com/firebase/firebase-js-sdk/issues
- npm.io page: https://npm.io/package/@firebase/crashlytics

## Dependencies (21)

- [tslib](https://npm.io/package/tslib.md) ^2.1.0
- [@firebase/util](https://npm.io/package/@firebase/util.md) 1.15.3
- [@opentelemetry/api](https://npm.io/package/@opentelemetry/api.md) 1.9.1
- [@firebase/component](https://npm.io/package/@firebase/component.md) 0.7.5
- [@opentelemetry/core](https://npm.io/package/@opentelemetry/core.md) 2.10.0
- [@firebase/installations](https://npm.io/package/@firebase/installations.md) 0.6.24
- [@opentelemetry/api-logs](https://npm.io/package/@opentelemetry/api-logs.md) 0.220.0
- [@opentelemetry/sdk-logs](https://npm.io/package/@opentelemetry/sdk-logs.md) 0.220.0
- [@opentelemetry/resources](https://npm.io/package/@opentelemetry/resources.md) 2.10.0
- [@opentelemetry/sdk-trace-web](https://npm.io/package/@opentelemetry/sdk-trace-web.md) 2.10.0
- [@opentelemetry/sdk-trace-base](https://npm.io/package/@opentelemetry/sdk-trace-base.md) 2.10.0
- [@opentelemetry/instrumentation](https://npm.io/package/@opentelemetry/instrumentation.md) 0.220.0
- [@opentelemetry/otlp-transformer](https://npm.io/package/@opentelemetry/otlp-transformer.md) 0.220.0
- [@opentelemetry/otlp-exporter-base](https://npm.io/package/@opentelemetry/otlp-exporter-base.md) 0.220.0
- [@opentelemetry/semantic-conventions](https://npm.io/package/@opentelemetry/semantic-conventions.md) 1.43.0
- [@opentelemetry/instrumentation-fetch](https://npm.io/package/@opentelemetry/instrumentation-fetch.md) 0.220.0
- [@opentelemetry/browser-instrumentation](https://npm.io/package/@opentelemetry/browser-instrumentation.md) 0.6.0
- [@opentelemetry/exporter-logs-otlp-http](https://npm.io/package/@opentelemetry/exporter-logs-otlp-http.md) 0.220.0
- [@opentelemetry/exporter-trace-otlp-proto](https://npm.io/package/@opentelemetry/exporter-trace-otlp-proto.md) 0.220.0
- [@opentelemetry/instrumentation-document-load](https://npm.io/package/@opentelemetry/instrumentation-document-load.md) 0.65.0
- [@opentelemetry/instrumentation-xml-http-request](https://npm.io/package/@opentelemetry/instrumentation-xml-http-request.md) 0.220.0

## Recent versions

- 0.1.0 (latest) — 2026-11-02
- 0.1.0-20261030160918 (next) — 2026-10-30
- 0.0.1-eap-crashlytics.d474e7535 (eap-crashlytics) — 2026-10-26
- 0.0.1-eap-crashlytics.fd9b1e1d0 — 2026-10-21
- 0.0.1-eap-crashlytics.64ada57eb — 2026-10-01
- 0.0.1-eap-crashlytics.e21972d2a — 2026-09-11
- 0.0.1-eap-crashlytics.659b578fb — 2026-07-21
- 0.0.1-eap-crashlytics.558ee841d — 2026-06-15
- 0.0.1-eap-crashlytics.06423a1af — 2026-05-27
- 0.0.1-eap-crashlytics.3dd4e65d9 — 2026-05-26

## README

# Firebase Crashlytics for Web Apps - Setup Guide

> [!IMPORTANT]
> Crashlytics for Web Apps is currently in **Private Preview** and available only for enrolled EAP (Early Access Program) customers. If you are not yet enrolled, please fill out the [sign-up form](https://forms.gle/FYADWGcA2k924Nqt7) to request access before configuring your application.

We’re excited for you to try out Crashlytics for your web app and share your feedback!

Crashlytics for **Next.js, React, Angular, React Router, and TanStack Router apps** includes client-side error reporting, de-minified stack traces, and a dedicated dashboard in the Firebase Crashlytics Console.

Crashlytics for web apps uses Cloud Logging for telemetry storage and Cloud Storage for sourcemap storage under the hood, which are paid products with a generous free tier. Learn more about [Logging pricing](https://cloud.google.com/stackdriver/pricing) and [Storage pricing](https://cloud.google.com/storage/pricing).

As a private preview customer, your experience is incredibly valuable to our team. Please submit bugs, API feedback, or feature requests directly to our team by emailing [crashlytics-web@google.com](mailto:crashlytics-web@google.com) or filling out this [feedback form](https://forms.gle/Us8GM4YuYcYZyRNK9).
---

## Table of Contents

- [Agent Setup Prompt](#agent-setup-prompt)
- [Step 1: Configure Firebase/Cloud Project](#step-1-configure-firebasecloud-project)
  - [Option 1: Using Firebase Console (Recommended)](#option-1-using-firebase-console-recommended)
  - [Option 2: Using Firebase CLI](#option-2-using-firebase-cli)
- [Step 2: Core SDK Installation & Initialization](#step-2-core-sdk-installation--initialization)
- [Step 3: Framework-Specific Setup Guides](#step-3-framework-specific-setup-guides)
- [Step 4: Force an Initial Crash](#step-4-force-an-initial-crash)
- [Debugging with AI Agents](#debugging-with-ai-agents)
  - [MCP Tools (`crashlytics:connect`)](#mcp-tools-crashlyticsconnect)
  - [REST API & Web Browser Metadata](#rest-api--web-browser-metadata)
- [Additional Configuration & References](#additional-configuration--references)

---

## Agent Setup Prompt

You can ask your coding agent to do everything for you! Use our sample prompt below to set up Crashlytics for your web app automatically.

When you copy this into your coding agent, make sure to do the following before running:

1. Fill in the correct `apiKey` and `appId` for your web app in `firebaseConfig`, which can be found in the Firebase Console in **Settings > General**.
   *Note: This assumes you already have a Firebase project created with a web app within.*
2. Point your coding agent to the GitHub README files in `packages/crashlytics/`.

```markdown
I would like to set up the Crashlytics JS SDK to my app. My firebase app config is as follows:

const firebaseConfig = {
  apiKey: "<YOUR_FIREBASE_API_KEY>",
  authDomain: "YOUR_PROJECT_NAME.firebaseapp.com",
  projectId: "YOUR_PROJECT_NAME",
  storageBucket: "YOUR_PROJECT_NAME.firebasestorage.app",
  appId: "<YOUR_FIREBASE_APP_ID>"
};

Follow the instructions in the Firebase Crashlytics Web Setup Guide GitHub READMEs for setting up the Crashlytics Web SDK. Start with the Cloud Project Setup (using the Firebase CLI), initialize the SDK, and then follow the Setup Guide for my app’s framework to enable automatic error collection. Do not set up programmatic error capturing for this project. Replace any of the "<SOME_VARIABLE>" values in the instructions with the appropriate values based on my Firebase app config above. Also make sure to set up source map uploading for stack trace de-obfuscation. If you encounter any issues during the setup process, please ask me and I can assist you further. Ensure that you have the necessary permissions to access the Firebase project and that you have the Firebase CLI installed and configured on your machine, logged in as me (ask me to log in on your behalf).
```

---

## Step 1: Configure Firebase/Cloud Project

Crashlytics for web leverages Google Cloud Logging, Error Reporting, and Storage under the hood. You can configure your project automatically using the Firebase Console (recommended) or the Firebase CLI (particularly useful when using coding agents).

> [!NOTE]
> If you are coming from an existing Google Cloud project and have not previously used Firebase with that project, you must accept the Firebase Terms of Service in the Firebase Console before proceeding with project setup.

### Option 1: Using Firebase Console (Recommended)

1. Navigate to the [Firebase Console Crashlytics page](https://console.firebase.google.com/u/0/project/_/crashlytics).
2. Select your project.
3. Click **Set up** and follow the steps in the console.

---

### Option 2: Using Firebase CLI

If you prefer configuring your project via the terminal or using an AI coding agent, run the following command:

```bash
firebase crashlytics:setup <YOUR_FIREBASE_APP_ID> --project <YOUR_FIREBASE_PROJECT_ID>
```

> [!NOTE]
> **Prerequisites**: Requires **Firebase CLI v15.34.2 or later**, Owner/Editor project permissions, and Blaze billing enabled.
> **Authentication**: Ensure you are authenticated and using the correct project:
>   ```bash
>   firebase login
>   firebase use <YOUR_FIREBASE_PROJECT_ID>
>   ```
> **Automated Setup**: This command automatically enables the required Telemetry APIs (`clienttelemetry.googleapis.com`, `firebasetelemetry.googleapis.com`, `firebasetelemetryadmin.googleapis.com`, and `firebasecrashlytics.googleapis.com`), updates API key restrictions for `clienttelemetry.googleapis.com` (if restricted), provisions the `firebase-telemetry` Cloud Logging bucket and routing sink, configures telemetry settings for your web app, and optionally sets up email alerts for new and regressed issues.

---

## Step 2: Core SDK Installation & Initialization

Before configuring framework-specific integrations, complete the core package installation and Firebase App singleton setup:

### Install Packages

Install the Firebase JS SDK:

```bash
npm install firebase
```

### Initialize Firebase App Singleton

Create a central configuration utility file (`src/lib/firebase.ts`) using the credentials found in the Firebase Console under **Settings > General**. Both manual trackers and framework interfaces leverage this initialized `FirebaseApp` instance.

```typescript
// src/lib/firebase.ts
import { initializeApp, getApps, getApp } from 'firebase/app';

const firebaseConfig = {
  apiKey: "<YOUR_FIREBASE_API_KEY>",
  authDomain: "<YOUR_AUTH_DOMAIN>",
  projectId: "<YOUR_FIREBASE_PROJECT_ID>",
  storageBucket: "<YOUR_STORAGE_BUCKET>",
  messagingSenderId: "<YOUR_MESSAGING_SENDER_ID>",
  appId: "<YOUR_FIREBASE_APP_ID>"
};

// Guarantee singleton initialization
export const app = getApps().length === 0
  ? initializeApp(firebaseConfig)
  : getApp();
```

---

## Step 3: Framework-Specific Setup Guides

> [!IMPORTANT]
> Make sure you have completed **Step 1 (Configure Firebase/Cloud Project)** and **Step 2 (Core SDK Installation & Initialization)** above before proceeding to your framework's setup guide below!

Select the guide matching your application framework:

- 🅰️ **[Angular Setup Guide](src/angular/README.md)**
- ⚛️ **[React Setup Guide](src/react/README.md)**
- 🛣️ **[React Router Setup Guide](src/react-router/README.md)**
- 🌼 **[TanStack Router Setup Guide](src/tanstack/README.md)**
- 🔺 **[Next.js Setup Guide](src/next/README.md)**

---

## Step 4: Force an Initial Crash

To verify that your setup is working and that crashes are properly delivered to Firebase Crashlytics, you can force a test crash in your application.

To ensure the crash is triggered on demand (and doesn't block application startup or fail server-side builds), add the following line inside a user interaction handler (such as a button click handler or event listener) in your application:

```typescript
throw new Error("Test Crash");
```

### Verify the Crash in the Console

1. Run your application and trigger the crash by performing the action (such as clicking the test button).
2. Open the [Firebase Console Crashlytics dashboard](https://console.firebase.google.com/u/0/project/_/crashlytics).
3. Select your project to view the newly logged crash report.

> [!NOTE]
> It may take a few minutes for new crash reports to appear in the Firebase Crashlytics console.

---

## Debugging with AI Agents

AI coding agents can assist in diagnosing and resolving web crashes directly within your development environment.

### MCP Tools (`crashlytics:connect`)
Crashlytics provides [Model Context Protocol (MCP)](https://firebase.google.com/docs/crashlytics/ai-assistance-mcp) tools that let agents query crash data—including issues, report groups, event payloads, and stack traces—without manual copy-pasting.

- **`crashlytics:connect` Prompt**: A guided interactive workflow that prioritizes top issues, investigates de-obfuscated sourcemaps against your local codebase, and helps the agent draft fixes. Learn more in the [Crashlytics AI assistance with MCP documentation](https://firebase.google.com/docs/crashlytics/ai-assistance-mcp#guided-workflow-prioritize-and-fix).

### REST API & Web Browser Metadata

You and your agents can also programmatically query the [Firebase Crashlytics REST API](https://firebase.google.com/docs/reference/crashlytics/rest).

Web error events and report groups expose browser-specific telemetry dimensions to help identify platform anomalies:
| Field | Description | Example |
|---|---|---|
| `browser.platform` | Client OS / platform architecture | `"macintosh"`, `"windows"`, `"linux"` |
| `user_agent.name` | Browser client application name | `"chrome"`, `"firefox"`, `"safari"`, `"edge"` |
| `user_agent.version` | Major/minor version of the browser client | `"150"` |
| `user_agent.original` | Raw User-Agent string from the client request | `"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)..."` |

---

## Additional Configuration & References

For advanced usage options and project configuration details, consult the following guides:

- 🚀 **[Advanced Usage Guide](docs/ADVANCED_USAGE.md)**:
  - 🏷️ **[App Versioning](docs/ADVANCED_USAGE.md#app-versioning)**: Set up build script helpers to tag telemetry with commit hashes/versions.
  - ⚡ **[Programmatic Error Capturing](docs/ADVANCED_USAGE.md#programmatic-error-capturing)**: Manually record handled exceptions with custom metadata.
  - 🧹 **[Force Flushing](docs/ADVANCED_USAGE.md#force-flushing-telemetry-records-flush)**: Upload queued error telemetry immediately before unload.
- ⚙️ **[Configuration Guide](docs/CONFIGURATION.md)**:
  - 🔔 **[Alerting](docs/CONFIGURATION.md#alerting)**: Configure email alerts for new and regressed issues via the Firebase Console or CLI, or set up advanced Cloud Monitoring alerts.
  - 🎚️ **[Sampling](docs/CONFIGURATION.md#sampling)**: Control telemetry volume and costs using the Admin API or Cloud Logging exclusion filters.
  - ⚙️ **[Enable/Disable Telemetry Collection](docs/CONFIGURATION.md#enabledisable-telemetry-collection)**: Programmatically turn telemetry collection on or off.
  - 📋 **[Log Schema](docs/CONFIGURATION.md#log-schema)**: Full reference for telemetry log fields and payload structures.

---
_Source: https://npm.io/package/@firebase/crashlytics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
