Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,13 @@ pnpm add @sentry/tanstackstart-react
<SplitSection>
<SplitSectionText>

Initialize Sentry in your [client entry point](https://tanstack.com/start/latest/docs/framework/react/guide/client-entry-point) `src/client.tsx`:
Create an `instrument.client.ts` file in your `src/` directory and initialize Sentry in it.

</SplitSectionText>
<SplitSectionCode>

```tsx {filename:src/client.tsx}
```tsx {filename:src/instrument.client.ts}
import * as Sentry from "@sentry/tanstackstart-react";
import { StartClient } from "@tanstack/react-start/client";
import { StrictMode, startTransition } from "react";
import { hydrateRoot } from "react-dom/client";

Sentry.init({
dsn: "___PUBLIC_DSN___",
Expand Down Expand Up @@ -132,6 +129,26 @@ Sentry.init({
replaysOnErrorSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ session-replay
});
```

</SplitSectionCode>
</SplitSection>

<SplitSection>
<SplitSectionText>

Then import this file as the **first import** in your [client entry point](https://tanstack.com/start/latest/docs/framework/react/guide/client-entry-point) `src/client.tsx`. This ensures Sentry initializes before any other code runs, so errors and events before hydration are captured.

</SplitSectionText>
<SplitSectionCode>

```tsx {filename:src/client.tsx}
// Sentry initialization should be imported first!
import "./instrument.client";

import { StartClient } from "@tanstack/react-start/client";
import { StrictMode, startTransition } from "react";
import { hydrateRoot } from "react-dom/client";

startTransition(() => {
hydrateRoot(
Expand Down
Loading