How to use the iframe-coordinator/dist/client.Client function in iframe-coordinator

To help you get started, we’ve selected a few iframe-coordinator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github purecloudlabs / iframe-coordinator / client-app-example / src / client.js View on Github external
import 'url-polyfill';

import { Client } from 'iframe-coordinator/dist/client';

document.getElementById('path').innerHTML = window.location.hash;

window.onhashchange = function() {
  document.getElementById('path').innerHTML = window.location.hash;
  document.getElementById('hostPath').innerHTML = iframeClient.asHostUrl(
    window.location.hash
  );
};

/****  SET UP THE IFRAME CLIENT LIBRARY ****/

let iframeClient = new Client({
  // This lets the example client work with the cli host by setting it's domain
  // as a valid host origin to post messages to. A production app will probably
  // need to conditionally set this.
  hostOrigin: `http://${window.location.hostname}:3000`
});

// Add a listener that will handled config data passed from the host to the
// client at startup.
iframeClient.addListener('environmentalData', envData => {
  // Transform link URLs to match top-level app.
  transformLinks();

  const appLocale = envData.locale;
  const now = new Date();
  const localizedDate = new Intl.DateTimeFormat(appLocale).format(now);
  console.log(

iframe-coordinator

Tools for coordinating embedded apps via iframes.

MIT
Latest version published 10 days ago

Package Health Score

73 / 100
Full package analysis

Similar packages