# React

`@newtalaria/react` **0.6.1** re-exports [`@newtalaria/browser`](https://docs.newtalaria.com/sdk/javascript.md) and adds an `ErrorBoundary`, React 19 error hooks, a `Profiler`, and optional React Router instrumentation.

Building Next.js? Install [`@newtalaria/nextjs`](https://docs.newtalaria.com/sdk/javascript/nextjs.md) instead.

## Install

```bash
npm install @newtalaria/react
```

## Initialise

```tsx
import { createRoot } from 'react-dom/client';
import { Talaria, ErrorBoundary, reactErrorHandler } from '@newtalaria/react';

Talaria.init({
  apiKey: 'tal_pk_prod_nz1_…',
});

const root = createRoot(document.getElementById('root')!, {
  onUncaughtError: reactErrorHandler(),
});

root.render(
  <ErrorBoundary fallback={<p>Something went wrong.</p>}>
    <App />
  </ErrorBoundary>,
);
```

The API key decides the environment.

## Verify

```ts
Talaria.captureException(new Error('Talaria test error'));
```

Run this once, then open **Issues** in the [dashboard](https://one.newtalaria.com). The test error shows as a new issue in the key's environment. Nothing there? See [troubleshooting](https://docs.newtalaria.com/sdk/javascript/troubleshooting.md).

## Next

See [configuration](https://docs.newtalaria.com/sdk/javascript/react/configuration.md), [errors](https://docs.newtalaria.com/sdk/javascript/react/errors.md), and [tracing](https://docs.newtalaria.com/sdk/javascript/react/tracing.md).
