← Decision Playground

Embed Decision Playground

Place the complete playground on any HTTPS website with one iframe. Visitors can edit questions, run decisions, inspect results, and use presets inside the frame. The frame scrolls independently when its contents exceed the chosen height.

To start the iframe in dark mode, append ?theme=dark to its URL. A visitor's saved Light or Dark choice takes precedence.

Quick start

  1. Deploy Decision Playground with a server-side Baseten key.
  2. Copy the HTML below and paste it into your website. This page fills in your deployment URL automatically.
  3. Publish your page and run a decision in the iframe to check the integration.

HTML iframe

<iframe
  src="https://YOUR-DOMAIN/embed"
  title="Decision Playground"
  width="100%"
  height="900"
  loading="lazy"
  referrerpolicy="strict-origin-when-cross-origin"
  allow="clipboard-write"
  allowfullscreen
  style="border: 0; max-width: 100%;"
></iframe>

Framework examples

React

export function DecisionPlaygroundEmbed() {
  return (
    <iframe
      src="https://YOUR-DOMAIN/embed"
      title="Decision Playground"
      width="100%"
      height="900"
      loading="lazy"
      referrerPolicy="strict-origin-when-cross-origin"
      allow="clipboard-write"
      allowFullScreen
      style={{ border: 0, maxWidth: '100%' }}
    />
  );
}

Render the component wherever the playground should appear. No package or client-side API key is needed.

Next.js App Router

// app/decisions/page.tsx
export default function DecisionsPage() {
  return (
    <main>
      <h1>Decision Playground</h1>
      <iframe
        src="https://YOUR-DOMAIN/embed"
        title="Decision Playground"
        width="100%"
        height="900"
        loading="lazy"
        referrerPolicy="strict-origin-when-cross-origin"
        allow="clipboard-write"
        allowFullScreen
        style={{ border: 0, maxWidth: '100%' }}
      />
    </main>
  );
}

This page is a Server Component; the iframe needs no client directive.

WordPress Custom HTML

<iframe
  src="https://YOUR-DOMAIN/embed"
  title="Decision Playground"
  width="100%"
  height="900"
  loading="lazy"
  referrerpolicy="strict-origin-when-cross-origin"
  allow="clipboard-write"
  allowfullscreen
  style="border: 0; max-width: 100%;"
></iframe>

In the WordPress block editor, add a Custom HTML block, paste the snippet, and preview the page.

Iframe attributes

AttributePurpose
srcPublic /embed URL on your Decision Playground deployment.
titleAccessible description for assistive technology.
width100% fits the containing element.
heightVisible frame height in pixels; adjust for your page. Overflow scrolls inside the iframe.
loadinglazy defers loading until near the viewport.
referrerpolicyLimits referrer data sent to the deployment.
allowDelegates clipboard writing for the Inspector Copy button in cross-origin frames, where the host permits it.
allowfullscreenAllows fullscreen if a browser or host page requests it.
styleRemoves the border and prevents overflow beyond the container.

Customization options

Set width and height to fit your page. The playground adapts to the iframe width and scrolls within its own frame when needed. Visitors can choose Light or Dark in the playground header. The choice is saved when browser storage is available; the current iframe session still works when third-party storage is blocked. Style the iframe's border, spacing, and container on the host page; host CSS cannot change the contents of a cross-origin iframe.

Security and allowed domains

The iframe calls /api/decide on its own deployment origin. Browser code and the host website never receive BASETEN_API_KEY. The API uses only that server environment variable. A public deployment consumes your Baseten quota and has no built-in rate limiting; use Baseten account limits or Vercel Firewall if you need request caps.

By default, any HTTPS website may frame /embed. To restrict hosts, set EMBED_ALLOWED_ORIGINS to comma-separated HTTPS origins, for example https://example.com,https://app.example.org, then redeploy. Entries must be exact origins without paths or trailing slashes. Invalid configuration blocks all framing. The setting controls framing, not direct API access. Other routes keep their existing headers.

Requests are limited to 4 MB. Compare mode makes two calls. Baseten may return 429 when its own capacity or account limits are reached; the playground retries those responses automatically up to three times.

Troubleshooting

Frequently asked questions

Does the host website need a JavaScript SDK?

No. The same public iframe URL works in HTML, React, Next.js, WordPress, and other sites.

Do visitors need an API key?

No. The deployment holds the Baseten key server-side. The API does not enforce its own usage limits, so set Baseten account limits or platform-level protection if the deployment is public.

Can the host page read playground data?

No. Browser same-origin rules isolate a cross-origin iframe from its parent page.

Can I embed on HTTP while developing?

The default policy permits the deployment's own origin for local testing. To test another host, use HTTPS.