From 224545c760ce5249f9dcbb45708ffa789295bf6d Mon Sep 17 00:00:00 2001 From: Adeola Adeyemo Date: Tue, 31 Mar 2026 15:24:20 +0100 Subject: [PATCH] feat: Create documentation for new journey embed SDK Signed-off-by: Adeola Adeyemo --- docs/journeys/sdk.md | 478 ++++++++++++++++++++++++++++++++ docs/journeys/web-components.md | 9 +- 2 files changed, 484 insertions(+), 3 deletions(-) create mode 100644 docs/journeys/sdk.md diff --git a/docs/journeys/sdk.md b/docs/journeys/sdk.md new file mode 100644 index 0000000..bf90b81 --- /dev/null +++ b/docs/journeys/sdk.md @@ -0,0 +1,478 @@ +--- +sidebar_position: 5 +--- + +# Journey Embed SDK + +The Journey Embed SDK provides a fluent builder API for embedding epilot Journeys into any website. It unifies both embedding backends — [Web Components](./web-components) and [iframes](./embedding) — behind a single, chainable interface. + +Use the SDK when you need **programmatic control** over how Journeys are embedded: building SPAs, reacting to user interactions, toggling full-screen on demand, or injecting pre-filled data at runtime. + +:::tip When to use the SDK vs. raw Web Components + +If you only need a static embed that never changes, the [`` Web Component](./web-components) is simpler — just drop an element in your HTML. The SDK is the better choice when your integration is driven by JavaScript: SPAs, dynamic data injection, or triggering full-screen from a button click. + +::: + +## Quick Start + +### 1. Add the SDK script + +The SDK is a single script that exposes `$epilot` on `window`. When using `.asWebComponent()`, the SDK **automatically loads** the web component script — no additional ` +``` + +When using `.asIframe()`, the SDK is entirely self-contained — no web component script is loaded. + +### 2. Embed a Journey + +Call `$epilot.embed()` after the DOM is ready and chain your configuration options. End the chain with an injection method (`append`, `prepend`, `before`, or `after`) to insert the Journey into the page: + +```html title="Inline embed via SDK" +
+ + +``` + +### 3. You're all set + +The Journey is injected into `#embed-target`. Read on for the full API reference and advanced scenarios. + +--- + +## Live Examples + +Browse interactive, runnable examples for every SDK scenario: + +- **[SDK Storybook](https://embed.journey.epilot.io/stories/?path=/docs/next-sdk--docs)** — inline, full-screen, inline-to-fullscreen, launcher, data injection, and more — with both iframe and web component backends. +- **[Web Component Storybook](https://embed.journey.epilot.io/stories/?path=/docs/next-web-component--docs)** — the same scenarios using raw `` attributes (no SDK). + +Use the **Controls** panel in Storybook to switch between backends and change options in real time. These examples work with **public Journeys** only — enter your own `journey-id` in the controls to see it in action. + +--- + +## Embed Targets + +The SDK supports two rendering backends. Choose one by calling the corresponding method in your chain: + +| Method | Backend | Notes | +| ------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `.asWebComponent()` | `` custom element | Recommended. Uses Shadow DOM — better performance and accessibility. The web component script is auto-loaded. | +| `.asIframe()` | `