Installation
Quick Start
Wrap your app withOutlitProvider and use the useOutlit hook in components.
- With Authentication (Recommended)
- Anonymous Only
If your app has user authentication, pass the user identity via the
user prop. This is the recommended approach as it automatically handles login/logout transitions.Using the Hook
Track custom events with theuseOutlit hook:
Provider Configuration
OutlitProvider
TheOutlitProvider initializes tracking and provides context to child components.
Props
Your organization’s public key.
API endpoint for sending events.
Automatically track pageviews on route changes.
Automatically capture form submissions.
Additional field names to exclude from form capture.
How often to flush queued events (ms).
Whether to start tracking automatically. Set to
false to wait for user consent. Use enableTracking() from the useOutlit hook after consent.Automatically identify users when they submit forms containing an email field. Extracts email and name (first name, last name, full name) using field name heuristics. Set to
false to disable and call identify() manually. See Auto-Identify for details.Track engagement metrics (active time on page). Emits engagement events on page exit and navigation.
Idle timeout in milliseconds for engagement tracking. After this period of no user interaction, the user is considered idle.
Track booking events from calendar embeds (Cal.com, Calendly).
Current user identity. When provided with email or userId, identifies the user. When null or undefined, clears the user identity. This is the recommended way to handle user identity in server-rendered apps.
An existing
Outlit instance to use instead of creating one internally. When provided, config props (publicKey, apiHost, etc.) are ignored and shutdown() is not called on unmount — the caller owns the instance lifecycle. Useful for sharing a single instance between imperative usage and React context.Client Mode
If you need to use the same Outlit instance both imperatively and via React context, pass an existing instance with theclient prop:
When using
client, the provider does not call shutdown() on unmount — you own the instance lifecycle. Config props like publicKey and trackPageviews are ignored.User Identity Patterns
Theuser prop is the recommended way to handle user identity. It’s simpler and more reliable than manual identify() calls because:
- Automatic lifecycle management: Login/logout transitions are handled automatically
- No timing issues: Identity is set before any events are tracked
- Cleaner code: No need for useEffect + identify() synchronization
Pattern 1: Client-Side Auth (Clerk, Auth0, etc.)
For auth libraries that provide React hooks:Pattern 2: Server-Side Auth (NextAuth, Lucia, etc.)
For auth systems where session is available server-side:When the
user prop changes (login/logout), the provider automatically calls setUser() or clearUser() internally. You don’t need to call these methods manually.Consent Management
If you need to wait for user consent before tracking:With Third-Party CMPs
- OneTrust
Hooks
useOutlit
The primary hook for tracking events and identifying users.Returns
Track a custom event.
Identify the current visitor.
Set the current user identity. Ideal for SPA authentication flows.
Clear the current user identity (on logout).
User identity namespace:
user.identify(options)- Identify the user
Get the current visitor’s ID. Returns
null if tracking is not enabled.Whether tracking is currently enabled. Will be
false if autoTrack is false and enableTracking() hasn’t been called.Enable tracking. Call this after obtaining user consent. Only needed if
autoTrack is false.Disable tracking and flush any pending events. Use this when a user declines or revokes consent.
Whether the tracker is ready.
useTrack
A convenience hook that returns just thetrack function:
useIdentify
A convenience hook that returns just theidentify function:
Activation event
Track the ordinary event selected as your activation signal after the milestone succeeds:Configure this event as your activation signal. Outlit Core derives lifecycle stages from ordinary events, and billing status comes from verified integrations such as Stripe. See Customer Journey.
Framework Examples
Next.js App Router
Next.js Pages Router
Remix
Common Patterns
Track on Mount
Track when a component mounts (e.g., page viewed):Track Form Submission
Track custom form events:Identify After Auth
If you can’t use theuser prop (e.g., the provider is in a different part of the tree), you can sync manually:
TypeScript
Full TypeScript support is included:Next Steps
Server-Side Tracking
Track events from your backend
Identity Resolution
Learn how profiles are merged