← Squads · 日本語

Embed guide

You can embed Squads formations in your blog, website or app for free (please read the terms of use). There are three ways, depending on what you need.

1. Paste the code (blogs and CMSs)

Create a formation in Squads and open “Embed code” from the </> button in the header (on smartphones, it is in the share menu). Choose a height (sideways boards default to a lower height), click “Copy code”, and paste it into your article's HTML. The “Sandbox” shows how it will look in a blog post.

<iframe src="https://squads.xxox-xxox-xxox.jp/embed#d=…" width="100%" height="600"
  style="border:0" loading="lazy" title="Formation"></iframe>

2. Use the SDK (app developers)

Pass data from your app and receive the result of user edits. Your host app is responsible for saving the data.

<div id="pitch" style="height: 600px"></div>
<script type="module">
  import { mount } from 'https://squads.xxox-xxox-xxox.jp/embed-sdk.js'

  const embed = mount(document.getElementById('pitch'), {
    src: 'https://squads.xxox-xxox-xxox.jp/embed',
    squad,                                        // board data
    options: { mode: 'edit', lang: 'en' },        // omit lang to follow the viewer's browser
    onChange: (squad) => save(squad),             // saving is up to the host
  })
</script>

3. Use postMessage directly

Without the SDK, send squads:init to the iframe.

window.addEventListener('message', (e) => {
  if (e.source !== iframe.contentWindow) return
  if (e.data?.type === 'squads:ready') {
    iframe.contentWindow.postMessage({ type: 'squads:init', v: '1.0', squad }, ORIGIN)
  }
})

For the message specification of methods 2 and 3 (options, PNG export and more), see “Squads embed protocol v1”.

Embed a versus (two teams)

A versus, with two squads side by side, can be embedded with any of the methods above.

let layout = null                                 // put a saved arrangement here, if any
const embed = mount(document.getElementById('pitch'), {
  src: 'https://squads.xxox-xxox-xxox.jp/embed',
  squad, opponent, layout,                        // passing opponent makes it a versus
  options: { mode: 'edit' },
  onChange: (squad, opponent, next) => {
    layout = next                                 // the versus arrangement (null for a single squad)
    save(squad, opponent, layout)                 // save it together with the squads
  },
})

// When the host replaces the squads, pass the received arrangement back
embed.set(updatedSquad, opponent, layout)

If you replace the squads without layout, the arrangement goes back to the start (the formation, no ball). When you switch the opponent to a different squad, do not pass it, since it does not fit that squad. For the shape of layout and its coordinates, see “Squads embed protocol v1”.

To create boards from AI assistants such as Claude or ChatGPT, see the AI assistant guide.

Please note