webeli / iframe-widget-boilerplate

React app rendered inside an iframe using zoid, like a widget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iframe-widget-boilerplate

React app rendered inside an iframe using zoid, like a widget.

Quick start

  • Clone the git repo: git clone --depth=1 https://github.com/sibiraj-sr/iframe-widget-boilerplate.git <YOUR_PROJECT_NAME>
  • Move to appropriate directory: cd <YOUR_PROJECT_NAME>
  • Run yarn install required dependencies
  • Run yarn start to start the webserver
  • Visit http://localhost:7297/ to view the app

Usage

  • Run yarn build to create optimized production build
  • Load widget-loader.js file in dist/js to load the widget

Sample installation script

(function () {
  window.WIDGET_CONFIG = {
    ASSETS_URL: '<ASSETS_URL>',
  };

  const scriptTag = document.createElement('script');
  scriptTag.type = 'text/javascript';
  scriptTag.async = true;
  scriptTag.src = `${window.WIDGET_CONFIG.ASSETS_URL}/js/widget-loader.js`;

  document.body.appendChild(scriptTag);
})();

About

React app rendered inside an iframe using zoid, like a widget

License:MIT License


Languages

Language:JavaScript 94.4%Language:SCSS 3.1%Language:HTML 2.6%