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

@thebcms/components-astro

v3.0.0

Published

Helper components for Astro

Readme

BCMS Astro Components (@thebcms/components-astro)

NPM Version

Helper components for rendering BCMS content in Astro — images with responsive src sets, rich text, and widgets.

For full setup, integration steps, and best practices, see the official documentation:

BCMS Astro Documentation →


Installation

Requirements: Astro 5+, @thebcms/client ^2.0.1, @thebcms/types ^2

npm i @thebcms/components-astro @thebcms/client @thebcms/types

Components Overview

| Component | Import path | Purpose | |---------------|-----------------------------------|----------------------------------------------| | BCMSImage | @thebcms/components-astro/image | Render BCMS media (IMG, SVG, GIF) with optimization | | BCMSContent | @thebcms/components-astro/content | Render entry content (rich text, widgets, media) |


BCMSImage

Renders BCMS media as optimized images. Supports IMG, SVG, and GIF. Produces responsive <picture> with WebP fallback and injects SVG when injectSvg is enabled in client config.

Props

| Prop | Type | Required | Description | |----------------|---------------------------------|----------|--------------------------------------------------| | media | Media \| MediaExtended \| PropMediaDataParsed | Yes | BCMS media object to display | | clientConfig | ClientConfig | Yes | BCMS client config (getConfig() from Client) | | altText | string | No | Alt text (falls back to media.altText or media.name) | | useOriginal | boolean | No | Use original image instead of src set | | sizeTransform| string[] | No | Limit to specific size transforms | | id | string | No | Element ID | | class | string | No | CSS class | | style | string | No | Inline style |

Example

---
import BCMSImage from '@thebcms/components-astro/image';
import { bcmsClient } from '../bcms-client';

const media = entry.meta.en.cover_image; // from BCMS entry
const config = bcmsClient.getConfig();
---

<BCMSImage
  media={media}
  clientConfig={config}
  altText={entry.meta.en.title}
  class="rounded-lg"
/>

BCMSContent

Renders BCMS entry content (rich-text nodes). Handles widgets, media embeds, and primitives. Pass widget components to customize how widgets render.

Props

| Prop | Type | Required | Description | |--------------------|------------------------------|----------|--------------------------------------------------| | items | EntryContentParsedItem[] | Yes | Content nodes from entry content (e.g. entry.content.en) | | widgetComponents | BCMSWidgetComponents | No | Map of widget name → Astro component | | nodeParser | (item) => string | No | Custom renderer for nodes (e.g. non-IMG media) | | clientConfig | ClientConfig | No | Required for media nodes (images) | | id | string | No | Element ID | | class | string | No | CSS class | | style | string | No | Inline style |

BCMSWidgetComponents

Object mapping widget names to components:

import type { BCMSWidgetComponents } from '@thebcms/components-astro/content';
import MyWidget from './MyWidget.astro';

const widgetComponents: BCMSWidgetComponents = {
  'my-widget': MyWidget,
};

Example

---
import BCMSContent from '@thebcms/components-astro/content';
import { bcmsClient } from '../bcms-client';
import type { BCMSWidgetComponents } from '@thebcms/components-astro/content';
import HeroWidget from '../components/HeroWidget.astro';

const widgetComponents: BCMSWidgetComponents = {
  hero: HeroWidget,
};

const config = bcmsClient.getConfig();
---

<BCMSContent
  items={entry.content.en}
  widgetComponents={widgetComponents}
  clientConfig={config}
  class="prose max-w-none"
/>

bcms-image (Custom Element)

The Image component uses a <bcms-image> custom element for images that need responsive src sets. It updates the srcset when the viewport resizes. The custom element is registered when image.ts is loaded — include it in your layout or entry point if you use the responsive image output.

// e.g. in layouts/Layout.astro or a client script
import '@thebcms/components-astro/image';

Links