Skip to main content

Installation

Quick Start

Wrap your app with OutlitProvider and use the useOutlit hook in components.

Using the Hook

Track custom events with the useOutlit hook:

Provider Configuration

OutlitProvider

The OutlitProvider initializes tracking and provides context to child components.

Props

publicKey
string
required
Your organization’s public key.
apiHost
string
default:"https://app.outlit.ai"
API endpoint for sending events.
trackPageviews
boolean
default:"true"
Automatically track pageviews on route changes.
trackForms
boolean
default:"true"
Automatically capture form submissions.
formFieldDenylist
string[]
Additional field names to exclude from form capture.
flushInterval
number
default:"5000"
How often to flush queued events (ms).
autoTrack
boolean
default:"true"
Whether to start tracking automatically. Set to false to wait for user consent. Use enableTracking() from the useOutlit hook after consent.
autoIdentify
boolean
default:"true"
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.
trackEngagement
boolean
default:"true"
Track engagement metrics (active time on page). Emits engagement events on page exit and navigation.
idleTimeout
number
default:"30000"
Idle timeout in milliseconds for engagement tracking. After this period of no user interaction, the user is considered idle.
trackCalendarEmbeds
boolean
default:"true"
Track booking events from calendar embeds (Cal.com, Calendly).
user
UserIdentity | null
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.
client
Outlit
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 the client 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

The user 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:
Which pattern should I use?
  • Client-side auth hooks (Clerk, Auth0): Use Pattern 1 with a client providers component
  • Server-side sessions (NextAuth, Lucia, custom JWT): Use Pattern 2 directly in the layout
Both patterns work equally well - choose based on how your auth library provides user data.
When the user prop changes (login/logout), the provider automatically calls setUser() or clearUser() internally. You don’t need to call these methods manually.
If you need to wait for user consent before tracking:

With Third-Party CMPs

Hooks

useOutlit

The primary hook for tracking events and identifying users.

Returns

track
(eventName: string, properties?: object) => void
Track a custom event.
identify
(options: IdentifyOptions) => void
Identify the current visitor.
setUser
(identity: UserIdentity) => void
Set the current user identity. Ideal for SPA authentication flows.
clearUser
() => void
Clear the current user identity (on logout).
user
object
User identity namespace:
  • user.identify(options) - Identify the user
getVisitorId
() => string | null
Get the current visitor’s ID. Returns null if tracking is not enabled.
isTrackingEnabled
boolean
Whether tracking is currently enabled. Will be false if autoTrack is false and enableTracking() hasn’t been called.
enableTracking
() => void
Enable tracking. Call this after obtaining user consent. Only needed if autoTrack is false.
disableTracking
() => void
Disable tracking and flush any pending events. Use this when a user declines or revokes consent.
isInitialized
boolean
Whether the tracker is ready.

useTrack

A convenience hook that returns just the track function:

useIdentify

A convenience hook that returns just the identify 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

Prefer the user prop instead. The pattern below works, but using the user prop on OutlitProvider is cleaner and handles the lifecycle automatically. See User Identity Patterns above.
If you can’t use the user 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