Remote DOM

Loading "Remote Dom 715sn"
πŸ‘¨β€πŸ’Ό When users interact with our journaling app, they expect a consistent, professional experience that feels native to the application they're using. Right now, our tag viewer uses raw HTML which means our UI is rendered in an iframe and cannot resemble the variety of agents using our MCP server because it can't integrate with the host application's design system. Users notice this inconsistency and it makes our app feel less polished and trustworthy.
The problem is that raw HTML gives us complete control but also complete responsibility for every aspect of the user interface. This leads to a fragmented user experience where each UI component feels like it belongs to a different application.
Instead, we can use Remote DOM to create UI components that automatically inherit the host application's design system. This means our tag viewer will look and feel like it belongs in whatever application the user is using, whether that's a chat interface, a dashboard, or a mobile app.
// New approach: Remote DOM with consistent components
const resource = createUIResource({
	uri: 'ui://weather-card/singapore',
	content: {
		type: 'remoteDom',
		framework: 'react',
		// some editors will syntax highlight a string followed by the /* js */ comment
		script: /* js */ `
			const stack = document.createElement('ui-stack');
			stack.setAttribute('direction', 'vertical');
			stack.setAttribute('spacing', '20');
			stack.setAttribute('align', 'center');

			const title = document.createElement('ui-text');
			title.setAttribute('content', 'Singapore');
			stack.appendChild(title);

			const temperature = document.createElement('ui-text');
			temperature.setAttribute('content', '88Β°F - Partly Cloudy');
			stack.appendChild(temperature);

			const details = document.createElement('ui-text');
			details.setAttribute('content', 'Humidity: 78% | Wind: 12 mph');
			stack.appendChild(details);

			root.appendChild(stack);
		`,
	},
	encoding: 'text',
})
Remote DOM uses JavaScript to create and manipulate DOM elements using predefined UI components like ui-stack, ui-text, and ui-button. These components are automatically styled and provide consistent behavior across the host application.
You need to implement the getTagRemoteDomUIScript function to create a Remote DOM version of the tag viewer. Here's what you need to know:
  • ui-stack - Container with layout properties (direction, spacing, align)
  • ui-text - Text content with automatic styling
const stack = document.createElement('ui-stack')
stack.setAttribute('direction', 'vertical')
stack.setAttribute('spacing', '20')
stack.setAttribute('align', 'center')

const title = document.createElement('ui-text')
title.setAttribute('content', 'Your content here')
stack.appendChild(title)

// "root" is globally available in your script
root.appendChild(stack)
There's more available from remote-dom, but we'll keep it simple for now.

Please set the playground first

Loading "Remote DOM"
Loading "Remote DOM"
Login to get access to the exclusive discord channel.
  • πŸ’»MCP UI
    MCP use case for average AI user
    hasan ⚑:
    Hey @Kent C. Dodds β—† πŸš€πŸ†πŸŒŒβš‘ while working with MCPs one concern keeps comint to me. Do you feel ave...
    • βœ…1
    3 Β· 4 hours ago
  • ⚑General
    Epic MCP Server
    Fede:
    Given the amount of questions around deployment and getting started, it would be cool to have an Epi...
    • βœ…1
    2 Β· 19 hours ago
  • ⚑General
    Cloudflare deployment
    Aaron Schwartz:
    Do you have any resources on deploying to a live cloudflare instance? I haven't dug through the work...
    • πŸ‘1
    • βœ…1
    4 Β· 21 hours ago
  • πŸ’»MCP UI
    MCP-UI UIResourceRenderer
    js.nz ⚑:
    Any comments on using UIResourceRenderer from @mcp-ui/client when building a client UI?
    • βœ…1
    1 Β· 19 hours ago
  • πŸ’»MCP UI
    Render data use cases
    Aaron Schwartz:
    I'm still wrapping my head around the Auth section, but I was confused during the UI render data sec...
    • βœ…1
    1 Β· 21 hours ago
  • πŸ’ͺAdv. MCP Features
    ⚑General
    Understanding Session and State Management for Remote MCP Server
    Kusten ⚑:
    I just completed the Advanced Features workshop, and the notifications/tools/list_changed section le...
    • βœ…1
    1 Β· a day ago
  • πŸ’»MCP UI
    nanobot questions
    Jangla ⚑:
    Anyone know how to change the db location? I've followed the idea of adding nanobot config to an ign...
    • βœ…1
    4 Β· 3 days ago
  • πŸ’»MCP UI
    nanobot fails to connect to mcp server in exercise MCP UI 3.1
    Dan:
    Had nanobot connecting successfully in previous exercises but I get the following error since moving...
    • βœ…1
    14 Β· 3 days ago
  • ⚑General
    Epic MCP server not initializing
    steve ⚑:
    I am attempting to configure the Epic MCP Server per Kent's instructions here: https://www.epicai.pr...
    • βœ…2
    3 Β· 4 days ago
  • πŸ’»MCP UI
    Issue: Goose not detecting MCP extension in UI Workshop exercise
    Nhalillo ⚑:
    Hi everyone! πŸ‘‹ Has anyone managed to properly configure Goose for the first exercise (Simple Raw H...
    • βœ…1
    5 Β· 5 days ago
  • πŸ’»MCP UI
    Issue: Goose not displaying HTML (remote DOM exercise)
    okram ⚑:
    Hi πŸ‘‹ Goose is not displaying the HTML. I have no diff between problem and solution and I enabled t...
    • βœ…1
    1 Β· 4 days ago
  • ⚑General
    What will tomorrows MCP hosts look like?
    Paul πŸš€:
    Hi Kent,

Thanks for putting together the course, I’m really enjoying it. Im interested if you have...
    • βœ…1
    2 Β· 5 days ago
  • πŸ’»MCP UI
    MCP UI repository - Unexpected option passed to `new Miniflare()` constructor?
    mark:
    So when I run the MCP UI repository and try start the first exercise I receive an error: "Unexpecte...
    • βœ…1
    11 Β· 5 days ago
  • ⚑General
    VS Code Copilot and Epic Workshop MCP Server
    Alexandre πŸš€:
    I might have missed something, but how do we install the Epic Workshop MCP Server so we can ask Copi...
    • βœ…1
    3 Β· 6 days ago
  • 🐣MCP Fundamentals
    πŸ’ͺAdv. MCP Features
    πŸ”MCP Auth
    πŸ’»MCP UI
    What about the usage of MCP Servers for some kind of chat interacting with a local LLM?
    frankfullstack ⚑:
    I would like to raise a general question about the usage of MCP Servers and how we could interact fr...
    • βœ…1
    5 Β· 11 days ago
  • 🐣MCP Fundamentals
    ⚑General
    It'd be really cool to have a basic deployment guide.
    BeyondLimits99 ⚑:
    The course has been amazing so far! I'd love to have a basic deployment guide just so I can practice...
    • βœ…2
    3 Β· 8 days ago
  • ⚑General
    non-related question: how do you rollout updates?
    mark:
    I'm very curious to hear: How do you roll-out new updates? do you use some kind of libary?
    • βœ…1
    5 Β· 13 days ago
  • 🐣MCP Fundamentals
    ⚑General
    How do you teach the LLMs to use ResourceTemplates and ResourceTemplatesList?
    frontendwizard:
    I'm playing around with building an mcp with claude and he has a tendency to go for json for everyth...
    • βœ…1
    8 Β· 11 days ago