Skip to main content

Overview

Panel artifacts are standalone web apps that run inside iframes and communicate with the Artifactuse SDK via postMessage. You can build custom panels using any framework - React, Vue, Svelte, or vanilla JavaScript.

Panels Repository

View source code, development docs, and contribution guidelines

Official Panels

How Panels Work

  1. SDK detects artifact type in AI response
  2. SDK loads appropriate panel URL in iframe
  3. Panel signals ready via panel:ready message
  4. SDK sends artifact data via load:artifact message
  5. Panel renders content and sends events back

Communication Protocol

Panels communicate with the SDK using the standard postMessage API. All messages use the artifactuse type for identification.

SDK → Panel: Loading Artifacts

When the SDK opens a panel, it sends a load:artifact message containing the full artifact data:

Artifact Code Formats

The code field contains different formats depending on the panel type:

SDK → Panel: Theme Updates

The SDK sends theme updates when the user changes themes:

Panel → SDK

Building a Custom Panel

1

Create project

Set up a project with your preferred framework (React, Vue, Svelte, vanilla JS)
2

Signal ready

Send panel:ready message when your panel loads
3

Handle load:artifact

Listen for load:artifact message and render the artifact content
4

Handle theme changes

Listen for theme:change message and update your UI
5

Send events

Emit events back to the SDK when user interacts
6

Deploy

Host on your CDN and configure SDK to use it

Vanilla JavaScript

Using the Bridge Helper

For convenience, use @artifactuse/shared which handles the message protocol:

JSON Sanitization

When parsing artifact.code that contains JSON, you may encounter unescaped newlines inside string values. This happens when the code extractor doesn’t properly escape literal newlines. Always sanitize before parsing:
Panels that need sanitization (parse JSON):
  • json-panel - displays JSON data
  • form-panel - parses form configuration
  • diff-panel - parses {oldCode, newCode} structure
  • editor-panel - parses canvas/video data
Panels that don’t need sanitization (raw code):
  • svg-panel - raw SVG markup
  • html-panel - raw HTML/Markdown
  • react-panel - raw JSX code
  • vue-panel - raw Vue SFC code
  • code-panel - raw JavaScript/Python

Theme Support

Panels should support both dark and light themes. The SDK sends theme updates via theme:change message.

CSS Variables

Use CSS variables for easy theming:

Registering Custom Panels

The SDK supports configurable panels that can be added, overridden, or disabled without modifying SDK source code.

Configuration Options

Panel Configuration Formats

Runtime Registration

Register panels at runtime with support for type aliases:

How Panel Routing Works

When the SDK detects an artifact, it looks up the panel URL using:
  1. Artifact type (e.g., form, social)
  2. Code language (e.g., json, svg, python)

Full Example

Default Panels

The SDK includes these built-in panel mappings:

Complete Panel Template

Here’s a complete template for building a custom panel:

Resources

Source Code

Browse official panel implementations

Development Guide

Step-by-step guide to building panels

Shared Utilities

Bridge, theme, and component utilities

Contributing

Contribute to official panels