Skip to main content

React Hooks

React hooks for using the Solute SDK in Next.js client components.
All hooks must be used in client components. Add 'use client' directive to your component file.

useTrack

Hook for tracking events.

Returns

(event: string, properties?: EventProperties) => void - Function to track events.

Example

useIdentify

Hook for identifying users.

Returns

(userId: string, traits?: UserTraits) => void - Function to identify users.

Example

useFeatureEnabled

Hook to check if a feature is enabled.
string
required
Feature flag key.
FlagOptions
Optional configuration.

Returns

boolean - true if the feature is enabled, false otherwise.

Example

useFeatureFlag

Hook to get a feature flag value.
string
required
Feature flag key.
FlagOptions
Optional configuration.

Returns

T | undefined - The flag value, or undefined if not found.

Example

useExperiment

Hook to get an experiment variant.
string
required
Experiment key.
FlagOptions
Optional configuration.

Returns

string | undefined - The variant key, or undefined if not found.

Example

useUser

Hook to get user information.

Returns

{ userId: string | undefined; anonymousId: string; sessionId: string } - User information object.

Example

useSolute

Hook to access the full SDK instance and all methods.

Returns

{ client: SoluteClient; track: Function; identify: Function; page: Function; group: Function; alias: Function; reset: Function; flush: Function } - Object with SDK instance and convenience methods.

Example

Next.js Integration Guide

Server Utilities