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

@rulecms/widget-react

v15.0.0

Published

React widget component for RuleCMS

Readme

@rulecms/widget-react

React widget component for RuleCMS

Installation

npm install @rulecms/widget-react

Usage

import { RuleCMSWidget } from '@rulecms/widget-react';

function App() {
  return (
    <RuleCMSWidget publishedKey="your-widget-key" />
  );
}

Server-side rendering

Fetch widget data on the server (or at build time), then render with pre-fetched data so images and content appear in the initial HTML.

1. Fetch on the server

import { fetchRuleCMSWidget } from '@rulecms/widget-react/server';
import { RuleCMSWidget } from '@rulecms/widget-react';

// Use a server-only env var — never NEXT_PUBLIC_* for the token
const data = await fetchRuleCMSWidget({
  publishedKey: 'your-widget-key',
  token: process.env.RULECMS_TOKEN!,
  endpoint: process.env.RULECMS_ENDPOINT, // optional; widget-cache recommended
  fetchOptions: {
    // Next.js App Router cache control, e.g.:
    next: { revalidate: 60 },
  },
});

2. Render with pre-fetched data

<RuleCMSWidget mode="pre-fetched" publishedKey="your-widget-key" initialData={data} />

No token is needed on the client in pre-fetched mode — the widget does not refetch in the browser.

Next.js App Router example

// app/page.tsx
import { fetchRuleCMSWidget } from '@rulecms/widget-react/server';
import { RuleCMSWidget } from '@rulecms/widget-react';

export default async function Page() {
  const data = await fetchRuleCMSWidget({
    publishedKey: process.env.RULECMS_PUBLISHED_KEY!,
    token: process.env.RULECMS_TOKEN!,
    fetchOptions: { next: { revalidate: 60 } },
  });

  return (
    <RuleCMSWidget mode="pre-fetched" publishedKey={process.env.RULECMS_PUBLISHED_KEY!} initialData={data} />
  );
}

Endpoint recommendation

For production, point endpoint at the widget-cache service (https://widget-cache.rulecms.com) for faster server fetches. The default (relative /api/v1/c/widget/get) is unchanged for backward compatibility.

Zero-JS widgets with RuleCMSWidgetServer (App Router)

On Next.js App Router (or any React Server Components environment), RuleCMSWidgetServer fetches and renders the widget entirely on the server — no widget JavaScript ships to the browser:

// app/page.tsx — a Server Component (no 'use client')
import { RuleCMSWidgetServer } from '@rulecms/widget-react/server';

export default function Page() {
  return (
    <RuleCMSWidgetServer
      publishedKey={process.env.RULECMS_PUBLISHED_KEY!}
      token={process.env.RULECMS_TOKEN!}
      fetchOptions={{ next: { revalidate: 60 } }}
      errorFallback={<p>Content is temporarily unavailable.</p>}
    />
  );
}

Error semantics: if the fetch fails, the component logs the error and renders errorFallback (default: nothing) — a CMS outage never breaks your page.

Which server API should I use?

| | RuleCMSWidgetServer | fetchRuleCMSWidget + mode="pre-fetched" | |---|---|---| | Widget JS in browser | none | yes (hydrates) | | Environments | App Router / RSC only | any React SSR (App/Pages Router, Remix, Express…) | | Data control | fetch happens inside the component | you own the fetch (share data, custom caching) |

See __docs__/move-to-ssr/PLAN-move-to-ssr.md for the full SSR roadmap.

Development

Install dependencies

npm install

Run development mode

npm run dev

Run tests

npm test

Run Storybook

npm run storybook

Build for production

npm run build

Publishing

Increment version

# Patch version (1.0.0 -> 1.0.1)
npm run version:patch

# Minor version (1.0.0 -> 1.1.0)
npm run version:minor

# Major version (1.0.0 -> 2.0.0)
npm run version:major

Publish to npm

npm run release

License

MIT