React Router and Remix
The same steps work for React Router in framework mode and for Remix.
npm install @flarepanel/webCreate one shared instance:
// app/analytics.ts
import { FlarePanel } from '@flarepanel/web';
export const op = new FlarePanel({
clientId: 'YOUR_CLIENT_ID',
trackScreenViews: true,
trackOutgoingLinks: true,
trackAttributes: true,
});Import it in app/root.tsx, so it starts on every page:
// app/root.tsx
import './analytics';The instance does nothing during server rendering; it starts in the browser. Client-side navigation counts as a screen view.
Track events
import { op } from '~/analytics';
export function UpgradeButton() {
return (
<button onClick={() => op.track('upgrade_clicked', { plan: 'team' })}>
Upgrade
</button>
);
}Identify a signed-in user, for example after the root loader returns them:
op.identify({ profileId: user.id, email: user.email });Self-hosting
export const op = new FlarePanel({
clientId: 'YOUR_CLIENT_ID',
apiUrl: 'https://api.example.com',
});For events from loaders and actions, use the server SDK.