Remote Rendering with Web Workers

This ad is not shown to multipass and full ticket holders
React Advanced
React Advanced 2026
October 23 - 26, 2026
London, UK & Online
Upcoming event
React Advanced 2026
React Advanced 2026
October 23 - 26, 2026. London, UK & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Learn how we built Argo, a powerful extensibility framework that allows developers to seamlessly extend Shopify's apps on every platform. Argo provides developers with APIs to execute behaviour on the main app and a component library that renders native UI identical to Shopify's own component whether it's on iOS, Android or Web. Behind the scenes, Argo uses web workers and an open sourced library called remote-ui to create a sandboxed execution environment for external scripts.

This talk has been presented at React Summit Remote Edition 2021, check out the latest edition of this React Conference.

FAQ

Argo is an extensible framework developed for Shopify that facilitates the rendering of remote content within Shopify's applications. It allows external scripts to define user interfaces, which are then rendered natively by the main application, ensuring a seamless integration of third-party developed UI components with Shopify's native content.

In Argo, remote rendering involves creating a JavaScript sandbox to securely execute external scripts in a background thread. This is achieved using web workers on web platforms and a headless JavaScript engine on iOS and Android. The external script communicates with the main application through a remote procedure call (RPC) layer and uses proxies to interact with the application's rendering process.

Developers can write their scripts for Argo using familiar programming languages like JavaScript and TypeScript. They can also utilize popular frameworks such as React or Vue to build their user interfaces, which Argo then renders natively across different platforms.

Argo ensures security by executing external scripts in a JavaScript sandbox, where the scripts can only access and execute APIs provided by Shopify. This controlled environment prevents unauthorized access and ensures that the external content behaves as expected without compromising the security of the main application.

Yes, React can be swapped out in the Argo framework. The framework is designed to be flexible, allowing the replacement of React with other client libraries like Vue.js or even vanilla JavaScript, depending on the developer's preference or the requirements of a particular project.

Argo processes user interactions with dynamically rendered UI by using a proxy function that captures events like button clicks. When an event occurs, the proxy function makes a call through the RPC layer to execute the appropriate callback defined in the external script, facilitating interactive and responsive user interfaces.

The RemoteUI library provides essential components for the Argo framework, such as the communication layer between the JavaScript sandbox and the main application, a remote component tree for operation by the external script, and a proxy layer for function invocation. This library supports the secure and efficient integration of external UI components into Shopify's applications.

Trish Ta
Trish Ta
32 min
14 May, 2021

Comments

Sign in or register to post your comment.
Video Summary and Transcription
The video delves into the development of Argo, an extensible framework that enables the rendering of remote content within Shopify apps. Remote rendering uses a JavaScript sandbox and an RPC layer to securely execute external scripts. Argo is built on top of the RemoteUI library, which provides essential components like the communication layer and remote component tree. The framework supports flexibility in technology choice, allowing developers to use popular frameworks like React or Vue.js for UI development. Security is a priority, with external scripts running in a sandbox to prevent unauthorized access. The video highlights the use of web workers for secure execution and separation between the main app and external code. Argo's architecture supports a seamless integration of third-party UI components with Shopify's native content, offering a uniform user experience across different platforms, including iOS and web. The talk also touches on the setup process, including creating a worker and setting up the RPC layer for data exchange.
Available in Español: Renderizado remoto con Web Workers

1. Introduction to Remote Rendering with Web Workers

Short description:

Today, I will walk you through how we built Argo, an extensible framework that allows rendering of remote content inside of Shopify's apps. The core concepts behind remote rendering include creating a JavaScript sandbox, implementing a remote procedure call layer, and using proxies. We aimed to enable remote rendering, provide a good user experience, a good developer experience, and a security layer.

Hi, everyone. My name is Trish Thao. Thanks for joining me for this talk about remote rendering with web workers. Today, I will walk you through how we built Argo, an extensible framework that allows rendering of remote content inside of Shopify's apps.

Here's what we'll be covering today. I'll talk about the core concepts. How we built Argo, the end-to-end flow, how we can swap out React. And I'll follow up by having a quick demo of all the pieces working together.

Here are the core concepts behind remote rendering. First, we need to create a JavaScript sandbox. This sandbox allows us to securely execute code in a background thread. The communication to the main thread can be achieved by sending messages. This is implemented as a web worker on web. On iOS and Android, this is implemented as a headless JavaScript engine. Next, we need to implement a remote procedure call layer, RPC for short. This is a protocol that enables one program to call the service in another program. Finally, we make use of proxies. A proxy is a wrapper that intercept and redefines the target's core operations, such as invoking functions or accessing properties.

I'll talk about how we built Argo. First of all, what we were trying to achieve is to enable remote rendering. What this means is allowing an external script to define the UI, and then let the main application render it natively. The framework allows the external script to exchange data with the main application. That results in UI being rendered and custom behavior to be executed. So the objectives we were trying to achieve are to provide a good user experience. Injected UI content is indistinguishable from Shopify's own native content on all platforms. We wanted to provide a good developer experience. External scripts can be built using familiar languages like JavaScript and TypeScript, and frameworks like React or Vue, and we also wanted to provide a security layer. The external script can only access and execute APIs provided by Shopify. At a high level, this isn't what we were trying to do. We have a JavaScript sandbox that loads an external script inside of it.

2. End-to-End Flow of Rendering Content

Short description:

Through an RPC proxy, the script can call the RenderUI inside the main application. Argo was built on top of a library called RemoteUI, which provides a communication layer, a remote component tree, and a proxy layer. The end-to-end flow involves setting up the worker, loading the external script, constructing the UI, and rendering it. The setup includes creating a worker, setting up the RPC layer, and establishing a communication channel. The receiver manages the component tree, and the controller specifies the UI implementation. Finally, the remote renderer converts the component tree into UI.

Through an RPC proxy, the script can call the RenderUI inside the main application. When a user interacts with the UI, for example, clicking on a button, if the handler is defined inside the external script, the main application can call the handler through the RPC layer.

Argo was built on top of a library called RemoteUI. This library provides the following. A communication layer between the JavaScript sandbox and the main application. A remote component tree that the external script can operate on and the host can render. A proxy layer to allow the host to call functions defined in the JavaScript sandbox and vice versa.

Now I'll talk to you about the end to end flow of how rendered, how rendered, how the content is rendered. On web, first the host does some set up steps to set up the worker. Then we load the external script. And then the external script constructs UI using our libraries. Then it calls the render. This results in the host receiving a message with the serialized component tree, which is finally rendered as UI.

Digging into the whole setup, we are building an extension component that can communicate with a web worker. We start by setting up the worker and the RPC layer. We create a worker with a worker.js file. I'll dive deeper into what this is later. And then we call create endpoint to create a communication channel between the host and a worker. This create endpoint function is provided by Remote UI. And then we return the extension. The endpoint call method. This is a proxy that allows functions from inside the worker to be executed by the host asynchronously via message passing.

Next we set up an instance of the remote receiver. This receiver manages an internal component tree that can be operated on in response to messages. We also set up a controller which specifies the implementation to use when rendering UI. In this example, we are allowing buttons to be rendered using the button component from the Polaris UI library. The host gets to decide which components will be used. This makes it possible to swap out components depending on what's needed.

The last step is to render the remote renderer component from the remote UI library and pass it the receiver and controller. The remote render is responsible for converting the component tree it receives into UI using the implementation specified by our controller.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced 2022React Advanced 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced 2023React Advanced 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
Joe Savona
Mofei Zhang
2 authors
The Talk discusses React Forget, a compiler built at Meta that aims to optimize client-side React development. It explores the use of memoization to improve performance and the vision of Forget to automatically determine dependencies at build time. Forget is named with an F-word pun and has the potential to optimize server builds and enable dead code elimination. The team plans to make Forget open-source and is focused on ensuring its quality before release.
Using useEffect Effectively
React Advanced 2022React Advanced 2022
30 min
Using useEffect Effectively
Top Content
Today's Talk explores the use of the useEffect hook in React development, covering topics such as fetching data, handling race conditions and cleanup, and optimizing performance. It also discusses the correct use of useEffect in React 18, the distinction between Activity Effects and Action Effects, and the potential misuse of useEffect. The Talk highlights the benefits of using useQuery or SWR for data fetching, the problems with using useEffect for initializing global singletons, and the use of state machines for handling effects. The speaker also recommends exploring the beta React docs and using tools like the stately.ai editor for visualizing state machines.
Routing in React 18 and Beyond
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Routing in React 18 brings a native app-like user experience and allows applications to transition between different environments. React Router and Next.js have different approaches to routing, with React Router using component-based routing and Next.js using file system-based routing. React server components provide the primitives to address the disadvantages of multipage applications while maintaining the same user experience. Improving navigation and routing in React involves including loading UI, pre-rendering parts of the screen, and using server components for more performant experiences. Next.js and Remix are moving towards a converging solution by combining component-based routing with file system routing.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
React 18's concurrent rendering, specifically the useTransition hook, optimizes app performance by allowing non-urgent updates to be processed without freezing the UI. However, there are drawbacks such as longer processing time for non-urgent updates and increased CPU usage. The useTransition hook works similarly to throttling or bouncing, making it useful for addressing performance issues caused by multiple small components. Libraries like React Query may require the use of alternative APIs to handle urgent and non-urgent updates effectively.

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured Workshop
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Next.js for React.js Developers
React Day Berlin 2023React Day Berlin 2023
157 min
Next.js for React.js Developers
Top Content
Featured WorkshopFree
Adrian Hajdin
Adrian Hajdin
In this advanced Next.js workshop, we will delve into key concepts and techniques that empower React.js developers to harness the full potential of Next.js. We will explore advanced topics and hands-on practices, equipping you with the skills needed to build high-performance web applications and make informed architectural decisions.
By the end of this workshop, you will be able to:1. Understand the benefits of React Server Components and their role in building interactive, server-rendered React applications.2. Differentiate between Edge and Node.js runtime in Next.js and know when to use each based on your project's requirements.3. Explore advanced Server-Side Rendering (SSR) techniques, including streaming, parallel vs. sequential fetching, and data synchronization.4. Implement caching strategies for enhanced performance and reduced server load in Next.js applications.5. Utilize React Actions to handle complex server mutation.6. Optimize your Next.js applications for SEO, social sharing, and overall performance to improve discoverability and user engagement.
Concurrent Rendering Adventures in React 18
React Advanced 2021React Advanced 2021
132 min
Concurrent Rendering Adventures in React 18
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
With the release of React 18 we finally get the long awaited concurrent rendering. But how is that going to affect your application? What are the benefits of concurrent rendering in React? What do you need to do to switch to concurrent rendering when you upgrade to React 18? And what if you don’t want or can’t use concurrent rendering yet?

There are some behavior changes you need to be aware of! In this workshop we will cover all of those subjects and more.

Join me with your laptop in this interactive workshop. You will see how easy it is to switch to concurrent rendering in your React application. You will learn all about concurrent rendering, SuspenseList, the startTransition API and more.
React Hooks Tips Only the Pros Know
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
Introducing FlashList: Let's build a performant React Native list all together
React Advanced 2022React Advanced 2022
81 min
Introducing FlashList: Let's build a performant React Native list all together
Top Content
Featured Workshop
David Cortés Fulla
Marek Fořt
Talha Naqvi
3 authors
In this workshop you’ll learn why we created FlashList at Shopify and how you can use it in your code today. We will show you how to take a list that is not performant in FlatList and make it performant using FlashList with minimum effort. We will use tools like Flipper, our own benchmarking code, and teach you how the FlashList API can cover more complex use cases and still keep a top-notch performance.You will know:- Quick presentation about what FlashList, why we built, etc.- Migrating from FlatList to FlashList- Teaching how to write a performant list- Utilizing the tools provided by FlashList library (mainly the useBenchmark hook)- Using the Flipper plugins (flame graph, our lists profiler, UI & JS FPS profiler, etc.)- Optimizing performance of FlashList by using more advanced props like `getType`- 5-6 sample tasks where we’ll uncover and fix issues together- Q&A with Shopify team
React, TypeScript, and TDD
React Advanced 2021React Advanced 2021
174 min
React, TypeScript, and TDD
Top Content
Featured Workshop
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.