Skip to content
KomashiKomashi

Embed widgets

Komashi widgets add a ready-made service selection or subscription interface to your website. Their content comes from your Komashi configuration, and the loader creates an iframe in the page where you place the script.

WidgetUse it forRequired resource ID
Service PickerDisplay a service’s plans and let a customer start a subscription flow.data-service-id
Subscription DetailsDisplay and manage a specific existing subscription.data-subscription-id

Open Control Center → Integration → Widgets to preview both views and copy their generated embed code. The Widget settings guide explains the page and its empty states.

Service Picker example and generated embed code

Copy the script into the HTML at the position where the widget should appear:

<script
src="https://komashi.com/widget/embed.js"
data-komashi-widget
data-service-id="YOUR_SERVICE_ID"
data-view="service-picker"
></script>

Replace YOUR_SERVICE_ID with an actual service ID from the REST API or another trusted Komashi resource. The generated example contains a placeholder; copying it without replacing the ID does not connect your service.

Use the script host generated by your own environment. Do not publish the local komashi-app.test address on a public website.

Render the subscription ID for the customer who is entitled to see that subscription:

<script
src="https://komashi.com/widget/embed.js"
data-komashi-widget
data-subscription-id="YOUR_SUBSCRIPTION_ID"
data-view="subscription-details"
></script>

Subscription Details example with an existing subscription and embed code

Use an individual subscription ID, not its group ID. The widget derives the service and provider from that subscription. A customer ID is not a substitute for the required subscription ID.

The browser receives the IDs placed in the HTML. Decide on your backend which customer and subscription the signed-in visitor is allowed to access; an arbitrary ID copied from a URL is not proof of that authorization.

AttributeMeaning
srcThe generated /widget/embed.js URL.
data-komashi-widgetMarks the script for initialization by the Komashi loader.
data-viewSet service-picker or subscription-details explicitly.
data-service-idThe service ID required for Service Picker.
data-subscription-idThe subscription ID required for Subscription Details.
data-customer-idOptional existing customer context. Only supply an appropriate customer for the integration.
data-redirect-urlOptional return destination for supported completed flows. Use an absolute URL that you control.
data-is-previewPreview mode used by the Control Center example. Omit it for the live customer embed.

No provider API key belongs in this script. Keep REST keys on your server.

For example, a Service Picker with a return destination adds:

<script
src="https://komashi.com/widget/embed.js"
data-komashi-widget
data-service-id="YOUR_SERVICE_ID"
data-view="service-picker"
data-redirect-url="https://your-website.example/thanks"
></script>

The return destination does not prove that payment succeeded. Read the subscription state when your application needs to grant access.

The iframe fills its container’s width. The loader and widget communicate its height so it can resize as the content changes. The widget language follows the provider’s configured language.

Allow the widget host in any Content Security Policy that restricts external scripts or frames. Payment flows may also open a separate page; retain normal browser navigation and popup behavior.

For multiple widgets, place all their marked script elements in the HTML before the loader’s first execution. The current loader initializes the script elements it discovers on that first run; there is no documented automatic rescan for embeds inserted later by a single-page application.

ProblemCheck
Blank or unavailable widgetReplace placeholder IDs, verify the data-view, and check that the configured resource still exists.
Works locally but not on the public siteUse the public embed host rather than the local .test domain.
Missing iframe or script loadCheck your CMS’s script restrictions and your site’s Content Security Policy.
Wrong customer or subscriptionCheck the backend mapping and the individual subscription ID.
Stale or unresponsive tabReload the page. Widget interaction sessions are temporary.
429 responseReduce reloads or requests and retry later. The embed and render endpoints are throttled.

Related: Widget settings, REST API integration, webhooks.