Skip to content

Feature request: dynamic islands should receive signed page context #178

Closed

Description

@vinnysgreen

Summary

A dynamic island is rendered in a separate request that has no current post or URL, so a block that needs to know “which page is this?” cannot be a dynamic island. Please let an island opt in to receiving the page context, signed the same way its attributes already are, so it cannot be faked.

Current behavior / evidence

  • The island runtime sends only { clientId, name, attributes, signature } to POST /wp-json/blockstudio/v1/island/render.
  • The endpoint renders a synthetic block built from just the block name and allow-listed attributes, in a REST request with no queried post.
  • Normal block templates, by contrast, get $block['postId'] / $block['postType'] (see the Context docs). In a fragment render, that page information is simply absent: get_the_ID()-style fallbacks have no page to fall back to, and block attributes are author-set values, not page-derived values, so there is no clean workaround.

Proposed behavior

Add an opt-in island context, for example island.context / a page-context flag in block.json. When enabled:

  • The marker carries the page context (at minimum the queried post ID and post type; URL if upstream considers it safe and useful) alongside the attributes.
  • The context is included in the HMAC signature payload — the payload already has a context field, but the marker currently never populates it — and the endpoint verifies the signature over name + attributes + context before trusting any of it.
  • Before rendering, the endpoint restores that context so the template sees the same $block['postId'] / post type it would in a normal render (upstream to decide whether that also means setting up the global post).
  • Any fragment cache key includes the context when context is enabled, so a page-specific fragment is never shared globally.

Security note

Signing is the point, not a nicety. An unsigned page ID in the fragment request would let anyone ask for a permission-gated or page-specific fragment for an arbitrary post. The context must be verified like the attributes already are, and must not bypass island eligibility, the attribute allow-list, or any permission checks on the block itself.

Use case

Any block whose output depends on the page it sits on — page-specific settings, related content, per-page gating — currently has to choose between being cacheable and knowing its page. This would let it be both.

Design question for upstream

Page context here means the queried page, not the Query Loop item a block might sit inside. If both are wanted, they should be distinguished in the payload rather than conflated.

Activity

  1. dnnsjsk commented on Oct 24, 2026

    @dnnsjsk
    Contributor

    Implemented and released in Blockstudio 7.7.8. Set island.context: true to opt into signed queried-page context. Fragment rendering restores that page's WordPress context, keeps page-specific cache entries separate, and verifies access before serving cached fragments. Unit and browser regression tests cover the new behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions