GuideClient reference
Complete reference for the GuideClient in the Knock JavaScript SDK.
Client for managing in-app guides, including real-time updates, location tracking, and engagement events.
Constructor#
Initializes a new guide client instance.
Parameters:
Constructor Options:
Returns: KnockGuideClient
Properties#
store
#A Tanstack Store instance containing the current state of guides, location, and other client data.
Type: Store<StoreState, (state: StoreState) => StoreState>
Core Methods#
fetch
#Fetches guides from the API based on the current targeting parameters and optional filters.
Parameters:
Returns: Promise<QueryStatus>
Example:
subscribe
#Subscribes to real-time guide updates via websocket connection.
Returns: void
Example:
unsubscribe
#Unsubscribes from real-time guide updates and cleans up websocket connections.
Returns: void
cleanup
#Performs complete cleanup of the guide client, including unsubscribing from websockets, removing event listeners, and clearing intervals.
Returns: void
Example:
Selection Methods#
selectGuides
#Selects multiple guides based on the current state and optional filters.
Parameters:
Filter Parameters:
Returns: KnockGuide<C>[]
Example:
selectGuide
#Selects a single guide based on priority, throttling rules, and group staging logic.
Parameters:
Returns: KnockGuide<C> | undefined
Example:
Location Tracking#
setLocation
#Manually sets the current location for guide activation rule evaluation.
Parameters:
Returns: void
Example:
Engagement Methods#
markAsSeen
#Marks a guide step as seen by the user.
Parameters:
Returns: Promise<KnockGuideStep | undefined>
markAsInteracted
#Marks a guide step as interacted with by the user.
Parameters:
Returns: Promise<KnockGuideStep | undefined>
markAsArchived
#Marks a guide step as archived by the user.
Parameters:
Returns: Promise<KnockGuideStep | undefined>
Example:
Debug Support#
The guide client supports debug mode through URL parameters:
knock_guide_key
- Forces a specific guide to showknock_preview_session_id
- Shows preview guides from a specific session
Example: