Iframe mini application

Create mini application

  1. In your Publisher Account, go to the Metaframe section.
  2. In the Custom sections block, click Add new app.
  1. If you want the mini application to be activated immediately after creation, set the Enable toggle to active.
Note
A green indicator is displayed next to the names of activated mini applications, while a black indicator is displayed next to deactivated ones.
  1. Choose Iframe as a mini application type.
  2. Enter the name of the mini application. Using the checkbox, you can choose whether the name is displayed in the header of the opened mini application.
  3. Enter the URL of a website or web application which will be displayed in the iframe.
  4. Upload the icon that will be displayed in the Metaframe menu for this mini application.
Notice

Requirements for the uploaded icon:

  • Image format: SVG.

  • Maximum image size: 12 KB.

  1. Choose if a mini application should be displayed in Metaframe before or after the user is logged in.
  2. Click Create app.

The created mini application can be edited or deleted.

How to configure mini application closing

If you check the Show this name in the section header box when creating a mini application, its name and close icon are displayed above the opened iframe.

If you don’‎t check the box, the logic for closing the iframe must be implemented in the mini application. To ensure the Metaframe widget processes the closing event correctly, add a script to the mini application code that sends a postMessage with the @xsolla-metaframe/mini-app:close type:

Copy
Full screen
Small screen
window.parent.postMessage(
  {
    type: '@xsolla-metaframe/mini-app:close',
    payload: null,
  },
  '*',
);

How to change mini application height

To match the iframe height to the mini application height, the logic for adjusting the height must be implemented in the mini application. To ensure the Metaframe widget correctly processes the height change event, add a script to the mini application code that sends a postMessage with the @xsolla-metaframe/mini-app:set-window-height type. You can also configure dynamic height adjustments when the mini application automatically sends a message whenever its height changes.

Note:

  • The height of the mini application’s root element should not be defined as a percentage of the parent element’s height. You can specify the value as max-content, auto, or a fixed height, e.g., in pixels.
  • The mini application must send the message whenever the height needs to be adjusted.
  • The number of messages sent is unlimited.
Example of implementing dynamic iframe height adjustment:
Copy
Full screen
Small screen
const setMiniAppWindowHeight = (heightInPixels: number) => {
  window.parent.postMessage(
    {
      type: '@xsolla-metaframe/mini-app:set-window-height',
      payload: {
        heightInPixels: heightInPixels,
      },
    },
    '*',
  );
};

const handleResize = () => {
  setMiniAppWindowHeight(document.body.clientHeight);
};

handleResize();

const observer = new MutationObserver(handleResize);
observer.observe(document.body, { childList: true, subtree: true });
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: January 30, 2025

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!