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

webim-adapter

v0.5.0

Published

Render WebIM builder pages inside any React app

Downloads

696

Readme

webim-adapter

Render pages built with the WebIM page builder inside any React app.

npm install webim-adapter
import { WebimPage } from 'webim-adapter';

<WebimPage
  apiUrl="https://api.example.com/api" // WebIM gateway base
  tenant="acme"                        // tenant slug (X-Tenant header)
  slug="landing"                       // published page slug
  locale="tr"                          // optional content locale
  mode="auto"                          // auto | light | dark
  fallback={<Spinner />}               // while loading
  errorFallback={<NotFound />}         // on 404 / network error
  onLoad={(bundle) => (document.title = bundle.seo?.title ?? bundle.title)}
/>

Only published pages render — drafts 404. The component fetches the page (GET /render/:slug) and the tenant's public theme/component libraries (GET /settings/public) in parallel, then renders the block tree with the same renderer the builder uses. Embedded WebIM forms submit to the public forms engine automatically.

SSR / prefetching

WebimPage fetches on mount. For server rendering, fetch the bundle yourself and render the pure component:

import { fetchPage, WebimContent } from 'webim-adapter';

// in a server loader
const bundle = await fetchPage({ apiUrl, tenant: 'acme', slug: 'landing' });

// in the component tree
<WebimContent bundle={bundle} mode="light" />

Script-tag embed (no React required)

For plain HTML / WordPress-style sites, build/webim-embed.js is a self-contained bundle (React included). Either drop containers and one tag:

<div data-webim-page data-api="https://api.example.com/api"
     data-tenant="acme" data-slug="landing" data-mode="auto"></div>
<script src="https://unpkg.com/webim-adapter/build/webim-embed.js"></script>

…or let the script tag place the page right where it sits:

<script src=".../webim-embed.js" data-api="…" data-tenant="acme" data-slug="landing"></script>

data-locale and data-mode (auto|light|dark) work on both. Containers added after load: window.WebimEmbed.scan(), or window.WebimEmbed.mount(el, { apiUrl, tenant, slug, locale, mode }).

Server-rendered HTML (zero-JS consumers / SEO)

The WebIM gateway serves a complete HTML document per published page:

GET /api/render/:slug/html?tenant=acme&locale=tr&mode=light

Browser-navigable (tenant rides the query string), with the page's SEO meta in the head and custom JS inlined. Static markup: theme, blocks, custom CSS/JS and iframes all work; React-stateful pieces (engine-wired form submits, sliders/tabs, Embed-block markup) stay inert — use the script embed when those matter. The endpoint allows iframing, so <iframe src=".../render/landing/html?tenant=acme"> is also a valid embed.

Node servers can render themselves via webim-adapter/ssr:

import { fetchPage, renderPageDocument, renderBundleHtml } from 'webim-adapter/ssr';

const bundle = await fetchPage({ apiUrl, tenant, slug });
const document = renderPageDocument(bundle, { mode: 'light', lang: 'en' });
const bodyOnly = renderBundleHtml(bundle); // splice into your own layout

Draft previews

Only published pages render publicly. To preview a draft, an authenticated editor mints a signed 30-minute token:

POST /api/pages/:id/preview-token   (Bearer auth)
→ { token, expires_in, slug }

The token unlocks that one page's current state everywhere:

<WebimPage … preview={token} />
await fetchPage({ …, preview: token });
GET /api/render/:slug/html?tenant=acme&preview=<token>

The Pages list in the dashboard has a "Copy preview link" action that mints a token and copies the ready-to-share HTML URL.

Lower-level exports

  • PageRenderer — render a raw blocks tree you already have.
  • renderRichContent(value) — render a rich-text field value from a collection entry. Image/video blocks carry align (left|center|right|full) as pure alignment plus wrap for the float that makes text flow around a left/right image (a block with no wrap key at all is legacy content and still floats), and image links honour target: '_blank' (rendered with rel="noopener noreferrer").
  • resolveTheme(meta, themes) — pick the theme tokens for a page.

Notes

  • Peer deps: react / react-dom 19+ (Google Font links rely on React 19 head hoisting).
  • A page's custom code (meta.custom.js and Embed blocks) executes in the host page — embed content only from tenants you trust, exactly like a tag manager snippet.
  • The WebIM gateway must allow CORS from the host origin.