Quickstart
React SPA Setup
Add DeepTracer to your React app (Vite, Create React App, or any SPA).
Using Next.js? Use the Next.js Quickstart instead — it includes server-side monitoring too.
Install
npm install @deeptracer/reactpnpm add @deeptracer/reactyarn add @deeptracer/reactbun add @deeptracer/reactAdd the provider
Wrap your app with DeepTracerProvider. This captures browser errors automatically.
import { DeepTracerProvider } from "@deeptracer/react"
function App() {
return (
<DeepTracerProvider
config={{
apiKey: import.meta.env.VITE_DEEPTRACER_KEY,
endpoint: import.meta.env.VITE_DEEPTRACER_ENDPOINT,
}}
>
<YourApp />
</DeepTracerProvider>
)
}Environment variable names depend on your build tool:
- Vite:
VITE_DEEPTRACER_KEY,VITE_DEEPTRACER_ENDPOINT - Create React App:
REACT_APP_DEEPTRACER_KEY,REACT_APP_DEEPTRACER_ENDPOINT - Next.js: Use the Next.js Quickstart instead
Log custom events
Use the useLogger hook anywhere in your app:
import { useLogger } from "@deeptracer/react"
export function CheckoutButton() {
const logger = useLogger()
const handleClick = () => {
logger.info("Checkout started", { cartItems: 3 })
}
return <button onClick={handleClick}>Checkout</button>
}Add an error boundary
Catch React rendering errors and report them automatically:
import { DeepTracerErrorBoundary } from "@deeptracer/react"
function App() {
return (
<DeepTracerProvider config={{ /* ... */ }}>
<DeepTracerErrorBoundary>
<YourApp />
</DeepTracerErrorBoundary>
</DeepTracerProvider>
)
}What's next?
- User context — Attach user info to all events
- Error capture — Manual error reporting with severity and breadcrumbs
- Full configuration — All config options