Overview
When you embed a shared dashboard (/share/application/:id) as an iframe, Upsolve
keeps its URL filter state in sync with your host application over the browser
postMessage
API. This lets you:
- Read the embedded view’s filter state — e.g. mirror it into your own URL so the dashboard’s filtered state is deep-linkable and survives a refresh.
- Drive the embedded view from your own UI — push filter changes down without reloading the iframe.
This applies to embeds of
/share/application/:id. Filters are expressed as
URL query params — see URL Filter Parameters
for the f_ omnibar param format.Message schema
Every message has atype and a numeric version v. Pin to the version you build
against; we bump v for any breaking change to a payload shape.
| Direction | type | Payload | Meaning |
|---|---|---|---|
| iframe → parent | embed:ready | { v } | The iframe’s listener is live. Safe to send the initial params. |
| iframe → parent | embed:params | { v, search } | The iframe’s filter state changed. search is a query string (leading ?) containing only filter params (f_* / filter_*) — auth tokens and other internal params are intentionally stripped (see Security). Empty string means no active filters. |
| parent → iframe | embed:set-params | { v?, search } | Apply these params to the embedded view. search may include or omit the leading ?; an empty string clears all filters. Messages with a v newer than the iframe understands are ignored. |
v: 1.
Security: lock down origins
The iframe never posts to"*". Instead, you declare your origin to the iframe
via a parentOrigin query param in the iframe src:
parentOrigin is a well-formed http(s) origin, only accepts
messages whose event.origin matches it, and only posts back to it. On your side,
always validate event.origin against the iframe’s origin before trusting a
message, and pass an explicit targetOrigin when you post — never "*".
Consumer reference implementation
Drop this into the page that hosts the iframe. It mirrors the iframe’s filter state into your own URL bar, and (optionally) pushes your URL’s filters down on load.Pushing filters live
To change the embedded view’s filters from your own UI after load — without reloading the iframe — post anembed:set-params message at any time:
Notes & gotchas
- Send params only after
embed:ready. If you postembed:set-paramsbefore the iframe is listening, it is silently dropped. Wait for the handshake. embed:paramsechoes. After you applyembed:set-params, the iframe will emit anembed:paramsreflecting the canonical (normalised) query string. The reference handler above mirrors it withhistory.replaceState, which does not re-emit — so there is no feedback loop.searchis the source of truth. Both directions speak the URL query string, so the samef_/filter_param formats documented in URL Filter Parameters apply.- Auth tokens stay in the iframe
src. Keepjwt/dbAuthTokenin the iframe URL you construct; they don’t need to be (and shouldn’t be) round-tripped throughpostMessage.