# JavaScript Error Tracking & Performance Monitoring

> Catch errors with source-mapped stack traces, trace slow requests, and replay the sessions that broke. Works in browsers, Node, edge, and serverless.

**URL:** https://sentry.io/for/javascript/

---

Resolve JavaScript errors with max efficiency, not max effort. Get actionable insights to resolve JavaScript performance issues with the ability to track, debug, and resolve JavaScript errors across platforms.

**Documentation:** [https://docs.sentry.io/platforms/javascript/](https://docs.sentry.io/platforms/javascript/)

## Install

### JavaScript

Grab the [Sentry JavaScript SDK](https://github.com/getsentry/sentry-javascript/):

```html
<script src="https://browser.sentry-cdn.com/latest/bundle.min.js"></script>
```

Configure your DSN:

```javascript
Sentry.init({
  dsn: 'https://<key>@sentry.io/<project>',
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 1.0,
  tracePropagationTargets: ['localhost', /^\/https:\/\/yourserver\.io\/api/],
});
```

See the [JavaScript docs](https://docs.sentry.io/platforms/javascript/) for full setup options.

### React

Grab the [Sentry React SDK](https://github.com/getsentry/sentry-javascript/):

```bash
npm install @sentry/react
```

Create an `instrument.js` file and add the Sentry initialization code. This file must be imported before any other imports in your application entry point:

```jsx
import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration(),
  ],
  tracesSampleRate: 1.0,
  tracePropagationTargets: [/^\//, /^https:\/\/yourserver\.io\/api/],
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});
```

Include the Sentry initialization file as the first import statement:

```jsx
import "./instrument";
import App from "./App";
import { createRoot } from "react-dom/client";
import * as Sentry from "@sentry/react";

const container = document.getElementById("app");
const root = createRoot(container, {
  onUncaughtError: Sentry.reactErrorHandler(),
  onCaughtError: Sentry.reactErrorHandler(),
  onRecoverableError: Sentry.reactErrorHandler(),
});
root.render(<App />);
```

See the [React docs](https://docs.sentry.io/platforms/javascript/guides/react/) for full setup options.

### Next.js

Signup and install Sentry with just one line of code:

```bash
npx @sentry/wizard@latest -i nextjs
```

See the [Next.js docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/) for full setup options.

### Vue

Grab the [Sentry Vue SDK](https://github.com/getsentry/sentry-javascript/):

```bash
npm install @sentry/vue
```

Configure your DSN:

```javascript
import { createApp } from "vue";
import * as Sentry from "@sentry/vue";

const app = createApp({
  // ...
});

Sentry.init({
  app,
  dsn: "https://<key>@sentry.io/<project>",
  integrations: [Sentry.browserTracingIntegration()],

  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,
  // Set tracePropagationTargets to control for which URLs distributed tracing should be enabled
  tracePropagationTargets: ['localhost', /^https:\/\/yourserver\.io\/api/],
});

app.mount("#app");
```

See the [Vue docs](https://docs.sentry.io/platforms/javascript/guides/vue/) for full setup options.

### Angular

Install with one line of code:

```bash
npx @sentry/wizard@latest -i angular
```

See the [Angular docs](https://docs.sentry.io/platforms/javascript/guides/angular/) for full setup options.

### Remix

Just run this command to sign up for and install Sentry:

```bash
npx @sentry/wizard@latest -i remix
```

See the [Remix docs](https://docs.sentry.io/platforms/javascript/guides/remix/) for full setup options.

### Svelte

To use the SDK, initialize Sentry in your Svelte entry point main.js before you bootstrap your Svelte app:

```javascript
// main.js / main.ts

import App from "./App.svelte";

import * as Sentry from "@sentry/svelte";

// Initialize the Sentry SDK here
Sentry.init({
  dsn: "__DSN__",
  release: "my-project-name@2.3.12",

  integrations: [Sentry.browserTracingIntegration()],

  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,

  // Set tracePropagationTargets to control for which URLs distributed tracing should be enabled
  tracePropagationTargets: ['localhost', /^https:\/\/yourserver\.io\/api/],
});

// Then bootstrap your Svelte app
const app = new App({
  target: document.getElementById("app"),
});

export default app;
```

See the [Svelte docs](https://docs.sentry.io/platforms/javascript/guides/svelte/) for full setup options.

### Electron

Install with one line of code:

```bash
npm install @sentry/electron --save
```

Configure your SDK:

```javascript
import * as Sentry from "@sentry/electron";
Sentry.init({ dsn: "https://<key>@sentry.io/<project>" });
```

See the [Electron docs](https://docs.sentry.io/platforms/javascript/guides/electron/) for full setup options.

### Ember

Grab the [Sentry Ember SDK](https://github.com/getsentry/sentry-javascript/):

```html
<script src="https://browser.sentry-cdn.com/11.7.0/bundle.min.js"></script>
```

Configure your DSN:

```javascript
Sentry.init({
  dsn: 'https://<key>@sentry.io/<project>',
  integrations: [new Sentry.Integrations.Ember()]
});
```

See the [Ember docs](https://docs.sentry.io/platforms/javascript/guides/ember/) for full setup options.

### Astro

Just run this command to install and register Sentry's Astro integration:

```bash
npx astro add @sentry/astro
```

See the [Astro docs](https://docs.sentry.io/platforms/javascript/guides/astro/) for full setup options.

### Nuxt

Just run this command to install and register Sentry's Nuxt integration:

```bash
npx @sentry/wizard@latest -i nuxt
```

See the [Nuxt docs](https://docs.sentry.io/platforms/javascript/guides/nuxt/) for full setup options.

## Features

### JavaScript Performance Monitoring

Quickly identify JavaScript [performance](/product/tracing/) issues before they become downtime. View the entire end-to-end [distributed trace](/product/tracing/) to see the exact, poor-performing API call and surface any related errors.

### Complete Stack Traces, Even When Minified

See the error and JavaScript stack trace previously only visible in your user's debug console. Apply source maps automatically to convert minified, compiled, or transpiled code back to its original form. Keep your JavaScript source maps private by uploading them directly to Sentry.

### Issues, replayed

Get to the root cause of an error or latency issue faster with context like DOM events, console logs, and network calls within one visual replay on your web application.

### Fill In the Blanks

See what the app was doing when the JavaScript error occurred: user interactions with component names, AJAX requests, console log messages and more. When frontend errors happen, Sentry can prompt users for feedback so you can compare their experiences to the data.

### Understand Where Tests Could Prevent Regressions

Quickly isolate Code Coverage for JavaScript bugs to see where testing could help fix the bug before release with our Codecov integration.

### Your Logs, Next to the Error

Send structured logs from the browser and your Node services to the same place as your errors and [traces](/product/tracing/). When a JavaScript error fires, the log lines around it are already there — no tab-switching to a separate logging tool to reconstruct what happened.

Learn more about [Logs in Sentry](/product/logs/).

## FAQ

**What is the difference between Sentry and traditional logging?**

Traditional logging provides you with a trail of events. Some of those events are errors, but many times they're simply informational. Sentry is fundamentally different because we focus on exceptions, or in other words, we capture application crashes. We discuss in more detail [here](/vs/logging/) and on our [blog](https://blog.sentry.io/lets-get-ready-to-monitor/).

**What frontend languages does Sentry support?**

Sentry supports every major frontend language, framework, and library. You can browse each of them [here](/platforms/).

**How much does Sentry cost?**

You can get started for free. Pricing depends on the number of monthly events, transactions, and attachments that you send Sentry. For more details, visit our [pricing page](/pricing/).

**How does Sentry impact the performance of my app?**

Sentry doesn't impact a web site's performance.

If you look at the configuration options for when you initialize Sentry in your code, you'll see there's nothing regarding minimizing its impact on your app's performance. This is because our team of SDK engineers already developed Sentry with this in mind.

Sentry is a listener/handler for errors that asynchronously sends out the error/event to Sentry.io. This is non-blocking. The error/event only goes out if this is an error.

Global handlers have almost no impact as well, as they are native APIs provided by the browsers.

**Can I send logs to Sentry?**

Yes. Sentry Logs lets you send, view, and query structured logs from your application alongside your errors and traces. Because logs sit next to the error and the trace that produced them, you get the granular context — retries, API failures, internal state — that spans and stack traces alone can miss, without switching tools.

Learn more about [Logs in Sentry](/product/logs/).

**What is Seer, Sentry's AI debugging agent?**

Seer is Sentry's AI debugging agent. It reads the full context Sentry already has — the error, its stack trace, the surrounding trace, logs, and profiles — to find the root cause of an issue and propose a fix. Seer can open a pull request with that fix, hand the work to an external coding agent, or review your PRs before they ship.

Learn more about [Seer](/product/seer/) and [Autofix](/product/seer/autofix/).

---

*Source: [sentry.io/for/javascript/](https://sentry.io/for/javascript/)*
