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

@render-policy/react

v0.1.8

Published

React adapter for @render-policy/core: render agent Markdown/HTML into a ref without dangerouslySetInnerHTML, with a streaming mode; A2UI Text and Image components under @render-policy/react/a2ui.

Readme

@render-policy/react

React adapter for @render-policy/core: render agent Markdown or HTML without dangerouslySetInnerHTML, with a streaming mode.

import { RenderPolicyProvider, RpMarkdown, RpHtml, useRenderPolicy } from '@render-policy/react';

const config = { mode: 'balanced', policy: { images: { hosts: ['cdn.example.com'] } } };

function App() {
  return (
    <RenderPolicyProvider config={config}>
      <RpMarkdown content={message.content} streaming={message.pending} className="message" />
    </RenderPolicyProvider>
  );
}
  • RenderPolicyProvider builds one renderer for the tree from config, or takes a prebuilt renderer. Keep config referentially stable (module scope or useMemo).
  • RpMarkdown / RpHtml render into an element (as, default div) that React owns but never fills. While streaming is true the growing text is rendered at most once per animation frame, with incomplete URLs withheld, unfinished code fences closed and settled blocks kept in place; when it turns false the final text is rendered once.
  • useRenderPolicy(content, { mode, streaming, scheduler, onDecisions }) returns a ref for an element of your own. The element must have no React-managed children. onDecisions receives the journal of every one-shot render and of the final render of a stream.
  • useRenderer() returns the renderer from the nearest provider, or a default balanced one.
  • Without a provider the components still work with the balanced defaults.
  • On the server the components render an empty container; content appears on the client.

A2UI Text and Image

@render-policy/react/a2ui has the basic catalog's Text and Image for an A2UI v0.9 surface of your own. They take the values your renderer resolved (after data binding and formatString) and run them through @render-policy/a2ui, an optional peer dependency you install for this entry.

import { A2uiGuardProvider, RpA2uiImage, RpA2uiText } from '@render-policy/react/a2ui';

const guard = { policy: { images: { hosts: ['cdn.example.com'] } }, onDecision: log };

<A2uiGuardProvider config={guard}>
  <RpA2uiText text={resolve(props.text)} variant={props.variant} componentId={id} />
  <RpA2uiImage url={resolve(props.url)} description={resolve(props.description)} fit={props.fit} variant={props.variant} fallback={<span>image blocked</span>} />
</A2uiGuardProvider>
  • RpA2uiText holds Text to the catalog's contract (Markdown without HTML, images or links) and inserts a sanitized fragment; h1–h5 render as headings and, like caption, without block wrappers. A bound value swapped later is rendered again through the same check.
  • RpA2uiImage checks the URL before an <img> exists: a blocked URL never reaches the DOM, so the browser makes no request, and fallback renders instead. The src is the value the guard returns (for example with the query string stripped).
  • variant and fit come from the agent: values outside the catalog's enums count as the defaults, so they never become a tag name or a class of the host page.
  • Classes follow the A2UI renderers' (a2ui-text h2, a2ui-image avatar), so their styles apply.
  • onDecisions receives the journal of each check; useA2uiGuard() returns the guard in use.
  • On the server RpA2uiText renders an empty element and RpA2uiImage only its fallback.

Requires React 18 or later.