---
title: "Remix"
description: "Initialize from app/root.tsx. The effect is skipped during server rendering and stays mounted across nested routes."
documentation: "https://tracwell.app/docs/frameworks/remix"
markdown: "https://tracwell.app/docs/frameworks/remix.md"
---

# Remix

> Initialize from app/root.tsx. The effect is skipped during server rendering and stays mounted across nested routes.

## Initialize Tracwell

```ts
import { useEffect } from "react";
import { Outlet } from "@remix-run/react";
import { createTracwell, type TracwellClient } from "tracwell";

let analytics: TracwellClient | undefined;

export default function App() {
  useEffect(() => {
    analytics ??= createTracwell({
      collectionMode: "product",
      projectKey: "tw_live_...",
    });
  }, []);

  return <Outlet />;
}
```

Remix client transitions use React Router and browser history, so the SDK records route changes automatically.

## Track an event

Keep the initialized client available to the component or service that owns the successful product outcome. Call `track()` only after that outcome completes.

```ts
const eventId = analytics.track("signup_completed", {
  plan: "starter",
  source: "pricing",
});

if (!eventId) {
  // Collection is blocked or the event did not pass validation.
}
```

See the [custom events guide](https://tracwell.app/docs/events.md) for naming, property limits, and verification.
