Ionic / Capacitor Integration

Use the <ekoo-widget> custom element in your Ionic applications (React, Vue, Angular)

ℹ️

SEO & GEO

Server rendering applies to web pages indexed by search engines, not to a mobile app. For your website, follow the SSR, SEO & GEO guide.

The widget auto-loads its config from the backoffice. Appearance attributes are optional overrides — no need to set them if the backoffice is configured.
Core attributes
data-ekooReq
string
Your Ekoo website UUID: backoffice, Settings → Organization, Organization ID field.
data-ekoo-product-idReq
string
Product reference (must match exactly what is in your Ekoo catalog).
data-ekoo-locale
string·default: auto
Locale code: fr, en, es, it, de, ar, cn, tw, hk, jp, kr, nl, tr, pl, pt, lu, be, ru. "auto" = navigator.language detection.
data-ekoo-variant
string
Stable reference of a widget configuration. The product, its audios, and its reviewers still come from data-ekoo-product-id; only the widget styling changes.
data-ekoo-review-id
string
ID of a specific audio review. If omitted: the product's default audio, otherwise the first published audio.
data-ekoo-on-event
string (fn name)
Name of a global window function called on each widget event (printed, played-0, played-25…).
Appearance — backoffice overrides
data-ekoo-direction
normal | reverse·default: normal
Expansion direction. normal = left-to-right, reverse = right-to-left.
data-ekoo-scale
number·default: 1
Scale factor (e.g. "1.2" for 20% larger).
data-ekoo-animation
string·default: pulse
Animation type for the widget icon at rest.
data-ekoo-animation-duration
string·default: continuous
Animation duration.
data-ekoo-always-open
boolean·default: false
If "true", the widget stays permanently expanded.
data-ekoo-show-image
boolean·default: true
Show or hide the product image in the widget.
data-ekoo-not-fully-clickable
boolean·default: false
If "true", only the play button is clickable.
data-ekoo-autoplay
boolean·default: false
Automatically start audio playback on load.
data-ekoo-audio-preload
metadata | none·default: metadata
Standalone 4.0.0: overrides the backoffice setting. “none” waits until the first click to load the file and disables autoplay.
data-ekoo-show-transcript
boolean·default: false
Show a button to read the audio transcript.
data-ekoo-show-speed-button
boolean·default: false
Show a playback speed control.
data-ekoo-closed-state-main-text
string
Main CTA text shown when the widget is collapsed.
data-ekoo-closed-state-secondary-text
string
Secondary text below the CTA when the widget is collapsed.
SPA & Shadow DOM
data-ekoo-mode
spa | static·default: auto
Forces rendering mode. Auto-detected (Next.js, Nuxt, React, Vue, Angular, Sapper). Only use if auto-detection fails.
data-shadow-mode
open | closed·default: open
"open" (default) enables inspection, external CSS access and analytics tracking. Set to "closed" to fully isolate the widget.
Global JS config
window.EKOO_FORCE_SPA = true
Forces SPA mode globally (alternative to data-ekoo-mode="spa" on each widget).
window.ekooShadowMode = "open"
Global Shadow DOM mode (alternative to data-shadow-mode on each widget).

Overview

In an Ionic / Capacitor app, use the <ekoo-widget> custom element. The script is loaded once in index.html. The element initializes when the page inserts it, reloads the product when data-ekoo-product-id changes and is destroyed when the page is removed: no Ionic hook is needed.

1. Load the Script in index.html

Add the Ekoo script to the <head> of your index.html. It will be loaded once when the application starts.

index.html
html
1<head>
2 <meta charset="UTF-8" />
3 <title>My App</title>
4 <script src="https://app.ekoo.co/widgets/widget-4.0.0-standalone.js" defer></script>
5</head>

2. Use the Custom Element

Place the <ekoo-widget> custom element in your template with the following attributes:

Custom element
html
1<ekoo-widget
2 data-ekoo="YOUR_WEBSITE_ID"
3 data-ekoo-product-id="MY_PRODUCT_ID"
4 data-ekoo-locale="fr"
5 data-shadow-mode="open"
6></ekoo-widget>
ℹ️

Note

As of widget 4.0.0, "open" is the default Shadow DOM mode, which ensures the widget works correctly as a Web Component in the Ionic context. The data-shadow-mode attribute can therefore be omitted.

3. Dynamic product reference

The <ekoo-widget> custom element observes attribute changes. To update the product ID dynamically, use setAttribute:

Dynamic product ID update
javascript
1const widget = document.querySelector('ekoo-widget')
2if (widget) {
3 widget.setAttribute('data-ekoo-product-id', newProductId)
4}

4. Ionic React

pages/ProductPage.tsx — Ionic React
tsx
1import React from 'react'
2import { IonContent, IonPage } from '@ionic/react'
3
4interface ProductPageProps {
5 productId: string
6}
7
8const ProductPage: React.FC<ProductPageProps> = ({ productId }) => {
9 return (
10 <IonPage>
11 <IonContent>
12 <h1>My product</h1>
13 {/* @ts-expect-error — custom element not typed by default */}
14 <ekoo-widget
15 data-ekoo="YOUR_WEBSITE_ID"
16 data-ekoo-product-id={productId}
17 data-ekoo-locale="fr"
18 data-shadow-mode="open"
19 />
20 </IonContent>
21 </IonPage>
22 )
23}
24
25export default ProductPage

5. Ionic Vue

views/ProductPage.vue — Ionic Vue
vue
1<template>
2 <ion-page>
3 <ion-content>
4 <h1>My product</h1>
5 <ekoo-widget
6 data-ekoo="YOUR_WEBSITE_ID"
7 :data-ekoo-product-id="productId"
8 data-ekoo-locale="fr"
9 data-shadow-mode="open"
10 />
11 </ion-content>
12 </ion-page>
13</template>
14
15<script setup lang="ts">
16import { IonPage, IonContent } from '@ionic/vue'
17
18defineProps<{
19 productId: string
20}>()
21</script>
💡

Vue: declare the custom element

To avoid Vue warnings about the custom element, add ekoo-widget to the compilerOptions.isCustomElement configuration in your vite.config.ts.

6. Ionic Angular

For Angular, you must add CUSTOM_ELEMENTS_SCHEMA to the module or component that uses the custom element:

product.page.ts — Ionic Angular
typescript
1import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
2
3@Component({
4 selector: 'app-product',
5 schemas: [CUSTOM_ELEMENTS_SCHEMA],
6 template: `
7 <ion-content>
8 <h1>My product</h1>
9 <ekoo-widget
10 data-ekoo="YOUR_WEBSITE_ID"
11 [attr.data-ekoo-product-id]="productId"
12 data-ekoo-locale="fr"
13 data-shadow-mode="open"
14 ></ekoo-widget>
15 </ion-content>
16 `,
17})
18export class ProductPage {
19 productId = 'my-product-123'
20}
ℹ️

CUSTOM_ELEMENTS_SCHEMA

Without CUSTOM_ELEMENTS_SCHEMA, Angular will throw an error because it does not recognize <ekoo-widget> as a native Angular component.

Go Further