Getting Started with Nerval

# Fetching from URL

By adding ?json=https://catfact.ninja/fact query at the end of iframe src you will be able to fetch from URL at widgets without additional scripts. This applies to editor page as well, the following link will fetch the url at the editor: https://jsoncrack.com/editor?json=https://catfact.ninja/fact

# Embed Saved JSON

Just like fetching from URL above, you can embed saved public json by adding the json id to "json" query ?json=639b65c5a82efc29a24b2de2

# Communicating with API

◼︎ Post Message to Embed

Communicating with the embed is possible with MessagePort, you should pass an object consist of "json" and "options" key where json is a string and options is an object that may contain the following:

{
  theme: "light" | "dark",
  direction: "TOP" | "RIGHT" | "DOWN" | "LEFT"
}

◼︎ On Page Load

⚠️ Important! - iframe should be defined before the script tag

⚠️ Note - Widget is not loaded immediately with the parent page. The widget sends its id attribute so you can listen for it as in the example below to ensure its loaded and ready to listen for messages.