Skip to content

Instantly share code, notes, and snippets.

@ShopifyEng
Last active December 1, 2021 16:06
Show Gist options
  • Save ShopifyEng/620e2645983d75382dd3a7e31b94e509 to your computer and use it in GitHub Desktop.
Save ShopifyEng/620e2645983d75382dd3a7e31b94e509 to your computer and use it in GitHub Desktop.
Remote Rendering: Shopify’s Take on Extensible UI - The host loads an extension and then renders it
// Host
import { createEndpoint } from "@remote-ui/rpc";
import { createRemoteReceiver } from "@remote-ui/core";
const endpoint = createEndpoint(new Worker("./sandbox.js"));
const receiver = createRemoteReceiver();
endpoint.call.load("https://somewhere.com/extension.js").then(() =>
endpoint.call.render(receiver.receive, {
setTitle: (title) => document.title = title
});
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment