Security and Sandbox

Use the right isolation boundary for trusted demos, user code, and AI-generated code.

Security model

Groundpack can execute code in different places. The right mode depends on whether that code is trusted.

ModeUse forBoundary
Same-origin main threadTrusted demos and examplesCan access the host page.
Same-origin workerTrusted code that should avoid blocking UIWorker isolation, same origin.
Cross-origin sandboxUntrusted user or AI-generated codeDifferent origin and sandboxed iframe.

Service worker setup

Virtual HTTP servers need a service worker so browser requests can be intercepted and forwarded to the registered virtual server.

  • The demo app serves website/public/__sw__.js.
  • Groundpack.boot() initializes preview routing in browsers when service workers are available.
  • Public apps should drive preview iframes from server-ready or port event URLs.