npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

a2ui-shadcn

v0.8.0

Published

A2UI protocol renderer mapping to shadcn/ui components

Readme

a2ui-shadcn

A production-grade npm package that maps the A2UI (Agent-to-User-Interface) protocol v0.9 to shadcn/ui components. Build dynamic, agent-driven UIs with React and Tailwind CSS.

Documentation & Live Demo

Installation

npm install a2ui-shadcn
# or
pnpm add a2ui-shadcn
# or
yarn add a2ui-shadcn

Requirements

  • React 18 or later
  • shadcn/ui (or compatible Tailwind-based UI components)
  • Tailwind CSS v4

Quick Start

  1. Set up shadcn/ui in your project (if not already):
npx shadcn@latest init
  1. Import and use the renderer:
import { A2UISurface } from 'a2ui-shadcn';

export default function App() {
  return (
    <A2UISurface
      surfaceId="my-surface"
      transport={{
        type: 'websocket',
        url: 'wss://your-agent-server.com/a2ui',
      }}
      onAction={(action) => {
        console.log('User action:', action);
      }}
    />
  );
}

Usage Examples

With Manual Transport (Testing)

Pass messages directly for testing or custom integrations:

import { A2UISurface } from 'a2ui-shadcn';

const messages = [
  {
    version: 'v0.9',
    createSurface: {
      surfaceId: 'test',
      catalogId: 'default',
    },
  },
  {
    version: 'v0.9',
    updateComponents: {
      surfaceId: 'test',
      components: [
        { id: 'root', component: 'Column', children: ['title', 'btn'] },
        { id: 'title', component: 'Text', text: 'Hello' },
        { id: 'btn', component: 'Button', text: 'Click', action: { event: { name: 'click' } } },
      ],
    },
  },
];

<A2UISurface surfaceId="test" messages={messages} onAction={(a) => console.log(a)} />

With A2UIProvider (Global Config)

import { A2UIProvider, A2UISurface } from 'a2ui-shadcn';

<A2UIProvider
  defaultTheme={{ primary: 'hsl(222.2 47.4% 11.2%)', radius: 'md' }}
  defaultDir="ltr"
  functions={{
    openUrl: ({ url }) => window.open(url, '_blank'),
    showAlert: ({ message }) => alert(message ?? ''),
  }}
  componentRegistry={{
    CustomChart: MyCustomChartComponent,
  }}
>
  <A2UISurface surfaceId="app" transport={{ type: 'websocket', url: 'wss://...' }} onAction={handleAction} />
</A2UIProvider>

With useA2UIDataModel

Access or update the reactive data model from outside the renderer:

import { A2UISurface, useA2UIDataModel } from 'a2ui-shadcn';

function MyStatus() {
  const [name, setName] = useA2UIDataModel<string>('/user/name');
  return <span>{name ?? 'Guest'}</span>;
}

// useA2UIDataModel must be used within A2UISurface tree

Register Client-Side Functions

import { registerFunction, registerContextFunction } from 'a2ui-shadcn';

registerFunction('openUrl', ({ url }) => {
  if (typeof url === 'string') window.open(url, '_blank');
});

registerContextFunction('formatDate', ({ value, format }) => {
  const date = value ? new Date(String(value)) : new Date();
  return date.toLocaleDateString(undefined, { dateStyle: 'medium' });
});

Register Custom Validation

import { registerCheck } from 'a2ui-shadcn';

registerCheck('customCheck', (args, resolveValue) => {
  const v = resolveValue(args.value);
  return v !== undefined && v !== null;
});

API Reference

Components

| Export | Description | |--------|-------------| | A2UISurface | Main component that consumes A2UI messages and renders the UI | | A2UIProvider | Global configuration context (theme, dir, functions, componentRegistry) |

Hooks

| Export | Description | |--------|-------------| | useA2UIDataModel(path) | Returns [value, setValue] for a JSON Pointer path. Must be used within A2UISurface. | | useA2UIConfig | Returns the A2UIProvider value or null |

Functions

| Export | Description | |--------|-------------| | registerFunction(name, handler) | Register a client-side function for functionCall actions | | registerContextFunction(name, handler) | Register a function that returns a value for action context resolution (e.g. formatDate) | | registerCheck(name, fn) | Register a custom validation function for component checks |

Lower-Level APIs

| Export | Description | |--------|-------------| | createDataModelStore(initial) | Create a reactive data model store | | createTransport(config) | Create a transport adapter (websocket, sse, manual) |

Type Exports

A2UIMessage, CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, ActionMessage, A2UIComponent, A2UITheme, TransportConfig, ComponentRegistry, ComponentAdapterProps, DynamicValue, JsonPointer

A2UISurface Props

| Prop | Type | Description | |------|------|-------------| | surfaceId | string | Unique identifier for the surface | | transport | TransportConfig | WebSocket, SSE, or omitted for manual | | messages | A2UIMessage[] | Initial messages (required when no transport) | | onAction | (action) => void | Callback when user triggers an action | | theme | A2UITheme | Override theme tokens | | componentRegistry | ComponentRegistry | Extend or override component mappings | | dir | 'ltr' \| 'rtl' | Layout direction | | className | string | CSS class for root container |

Transport Options

| Type | Config | Description | |------|--------|-------------| | websocket | { type: 'websocket', url: string } | Bidirectional real-time streaming | | sse | { type: 'sse', url: string, actionEndpoint?: string } | Server-Sent Events; actions sent via separate endpoint | | manual | { type: 'manual' } | Provide messages via messages prop |

Component Catalog

Over 30 A2UI components are supported:

Layout: Column, Row, Box, Card, Accordion, Tabs, Carousel

Content: Text, Image, Icon, Video, Audio, Markdown, CodeBlock, Divider

Input: TextField, CheckBox, Switch, Slider, ChoicePicker, DateTimeInput, FileUpload

Interactive: Button, Link, Menu

Data: DataTable, List

Feedback: ProgressIndicator, Badge, Snackbar

Navigation: AppBar, NavigationDrawer, BottomNavigation

Built-in Validation

Built-in checks: required, regex, minLength, maxLength, min, max, email. Use registerCheck to add custom checks.

Built-in Functions

  • openUrl – opens a URL in a new tab
  • showAlert – shows an alert dialog
  • formatDate – formats a date for context resolution

Features

  • Full A2UI v0.9 compliance (createSurface, updateComponents, updateDataModel, deleteSurface)
  • 30+ component adapters mapped to shadcn/ui primitives
  • Reactive data model with JSON Pointer support
  • Two-way binding for input components
  • Transport adapters: WebSocket, SSE, Manual
  • RTL layout support
  • Custom component registry and theme overrides
  • Action handling: event (server) and functionCall (client)
  • sendDataModel: true – include full data model in every action
  • Context resolution: path bindings and FunctionCall in action context

Documentation

Visit https://a2ui-shadcn.shahnazar.me for:

  • Complete API reference
  • Interactive playground
  • Usage guides and examples
  • Theming documentation
  • RTL setup guide
  • Custom component creation

License

MIT © Reza Shahnazar

Links