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

@bettercms-ai/react

v0.5.0

Published

BetterCMS for React apps (Vite and other client-rendered React): provider, hooks, draft mode by link, and the section and field components.

Readme

@bettercms-ai/react

BetterCMS for client-rendered React apps (Vite, CRA, any SPA). For Next.js use @bettercms-ai/next, for Astro @bettercms-ai/astro.

npm i @bettercms-ai/react
VITE_BCMS_API_URL=https://api.bettercms.ai
VITE_BCMS_WORKSPACE=your-workspace
VITE_BCMS_PROJECT_ID=your-project-id
// main.tsx
import { BcmsProvider } from "@bettercms-ai/react";
createRoot(el).render(<BcmsProvider env={import.meta.env}><App /></BcmsProvider>);

// a page
import { BcmsBlocks, usePage, useComponents } from "@bettercms-ai/react";
export function Home() {
  const { data: page } = usePage("home");
  const { data: components } = useComponents();
  return page ? <BcmsBlocks blocks={page.blocks} components={components} /> : null;
}

Hooks: usePage(slug), useEntry(slug), useEntries(opts), useLayout(), useComponents(), useBcmsQuery(key, read); each returns { data, error, loading }.

Components (the same markup as @bettercms-ai/next): BcmsBlocks, BcmsSections (inside <BcmsProvider> and given no blocks, <BcmsSections page="home"> reads the page's order itself, so the app's own sections render in the order the CMS page lists them), BcmsSection, BcmsField, BcmsImage, BcmsButton, BcmsForm, BcmsSearch, and BcmsDraftBridge, which lets the editor re-render drafts with your own components.

Your own components, editable

Spread a binding onto your own elements and the visual editor binds them:

import { entryAttrs, entryField, fieldAttrs, sectionRootAttrs } from "@bettercms-ai/react";

<h1 {...fieldAttrs("hero-title", page.fieldStyles)}>{title}</h1>
<article {...entryAttrs(post)}><h3 {...entryField(post, "title")}>{post.data.title}</h3></article>

Live

Every hook re-reads when content is published (pass liveSrc, or set VITE_BCMS_LIVE_URL), and when the visual editor asks the page to re-render. Re-reading keeps the current page on screen until the new data arrives. useBcms().refresh() re-reads on demand. In draft mode the provider also stamps <html data-bcms-draft="1"> and loads the click-to-edit overlay.

Draft mode

No server needed. The editor's "Preview on site" link opens /api/draft?token=…&redirect=/page on your site; an SPA host serves your app there, and <BcmsProvider> checks the token with BetterCMS, keeps it for the tab and moves to redirect. Reads then return drafts. useBcms().exitDraft() leaves draft mode. Set draftPath on the provider if your app uses another path (and the same path in the project's integration settings).

Your host must serve the app at that path, as it does for any client-side route: Netlify /* /index.html 200 in _redirects, a Vercel rewrite of /api/draft to /index.html (Vercel keeps /api for functions otherwise), and in vite dev no proxy on /api. GitHub Pages cannot rewrite: set draftPath to a path your app serves (/draft) and the same path in the integration settings. A token the backend refuses, or a check that cannot reach it, leaves the app published; an expired token is dropped the next time the app loads.