Rendering guides
How to render guides to power your in-product messaging.
Once you've created a guide, you'll need to render it in your product using the guides API. This involves fetching the guide data from Knock and displaying it to your users based on their eligibility. You can render guides using Knock's client-side SDKs, which provide built-in state management and helper methods, or by directly calling the guides API to build a custom implementation. Below we cover both approaches and how to filter guides to show the right content to your users.
Fetching guides
#You can fetch guides using Knock's client-side SDKs or by directly calling the guides API.
Client-side SDKs
#Knock exposes a set of client SDKs that provide helpers and logic to make it easier to work with guides in your product. Simplify your guides implementation by leveraging the SDK's guides provider and associated methods for accessing the fetched guides and their steps.
Features | Pre-built UI components | |||
Hooks for building custom UI components | ||||
State management for guides | ||||
Low-level API bindings and state management for building custom UI components |
Key SDK resources
#When working with Knock's SDKs to fetch and render guides, you'll use the following components and hooks:
- KnockGuideProvider. Provider component that fetches guides and manages guide state.
- useGuide. Hook to fetch a single guide by type or key.
- useGuides. Hook to fetch multiple guides.
- useGuideContext. Hook to access the guide client for advanced use cases.
Guides API
#You can also directly call the guides API to fetch guides and render them in your product. This approach gives you flexibility and full control over the rendering process, but requires you to build your own state management and UI components. We highly recommend using the SDKs as they provide a robust set of tools and helpers for working with guides.
Filtering guides
#You can fetch guides by either a type or a key to select a guide from the fetched set of guides. Here's how to think about choosing between these two selectors:
When multiple guides exist for a single type (e.g, a generic "Banner" component that could be used multiple times across many guides), Knock will prioritize guides chronologically, starting with the oldest guide. You can control the order of prioritzation by ordering your guides in the Knock dashboard.