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

@postkit/astro

v0.2.0

Published

Postkit components and Markdown integration for Astro

Readme

Postkit for Astro

@postkit/astro renders Postkit declarations through Astro MDX, provides Chakra context for every isolated React rendering boundary, and hydrates only components that require a React runtime.

When to use it

Use this adapter when an Astro site needs the PostKit component contract in imported MDX or content collections. It owns the Astro-to-React bridge and selective hydration policy while leaving content loading, layouts, and asset handling to the site.

Install

npm install @postkit/astro @postkit/react

Enable Astro's React and MDX integrations:

npx astro add react mdx
npm install @astrojs/markdown-remark

Add the Postkit integration and its unified Markdown processor:

// astro.config.ts
import mdx from '@astrojs/mdx';
import react from '@astrojs/react';
import { defineConfig } from 'astro/config';
import { createPostkitAstroMdxOptions, postkitAstro } from '@postkit/astro';

export default defineConfig({
  integrations: [postkitAstro(), react(), mdx(createPostkitAstroMdxOptions())],
});

createPostkitAstroMdxOptions() selects Astro's unified processor because Postkit's base Markdown lifecycle uses Remark plugins. Additional Remark plugins belong in the Postkit preset's before or after lists, while Rehype configuration can be passed alongside it:

mdx(
  createPostkitAstroMdxOptions({
    postkit: {
      after: [remarkReadingTime],
    },
    rehypePlugins: [rehypeSlug],
  }),
);

postkitAstro() uses Chakra's host-native defaultSystem unless the site provides a module that default-exports its own SystemContext:

postkitAstro({
  chakraSystem: './src/styles/postkit-system.ts',
});

Opt into PostKit's standalone preset from that module when desired:

import { createPostkitSystem, postkitDefaultTheme } from '@postkit/react';

export default createPostkitSystem({ preset: postkitDefaultTheme });

The relative path resolves from the Astro project root and is imported by both the server renderer and hydrated islands. This avoids trying to serialize a Chakra system through Astro island props.

Render MDX

Pass the component map to imported MDX:

---
import Article from '../content/article.mdx';
import { postkitAstroComponents } from '@postkit/astro/components';
---

<Article components={postkitAstroComponents} />

Content collections use the same map:

---
import { render } from 'astro:content';
import { postkitAstroComponents } from '@postkit/astro/components';

const { Content } = await render(Astro.props.entry);
---

<Content components={postkitAstroComponents} />

Use Postkit's JSX declarations in Astro MDX:

<Audio src="/episode.mp3" title="Episode 12" />

<Carousel items={[{ title: 'First slide' }, { title: 'Second slide' }]} />

<ShareActions
  url="https://example.com/posts/launch"
  services={['native', 'copy', 'bluesky']}
/>

<SocialPost
  href="https://bsky.app/profile/ada.example/post/abc"
  service="bluesky"
/>

MDX treats braces as JavaScript expressions, which conflicts with the brace-attribute syntax used by Remark directives. Reserve ::postkit-*{...} declarations for plain Markdown pipelines and use the equivalent JSX declaration in .mdx files.

Site components take final precedence:

import { createPostkitAstroComponents } from '@postkit/astro/components';

export const articleComponents = createPostkitAstroComponents({
  h2: ArticleHeading,
  Callout,
});

Hydration policy

Audio and Video use native browser controls, while AppearsOn, Figure, and the current Chart renderer are static, so Astro emits them without a client runtime. Disclosure also works natively without hydration. Carousel, CodeBlock, CodeGroup, LinkPreview, NewsletterSignup, Poll, ShareActions, SocialPost, and Tabs use client:visible and hydrate only when they approach the viewport. This keeps forms, sharing, runtime link resolution, and consent-gated embeds interactive without shipping a page-wide React root.

Poll selections are local unless the host supplies persistence. Host callbacks such as onVote belong inside a hydrated React wrapper; functions cannot be serialized as props across an Astro island boundary.

Prefer the items declaration for carousels in portable Markdown. Rich MDX children cross an Astro-to-React slot boundary and should be reserved for site-owned wrappers that control their hydration behavior.

Public API

  • postkitAstro(options?)
  • createPostkitAstroMdxOptions(options?)
  • postkitAstroComponents
  • createPostkitAstroComponents(overrides?)
  • Individual Astro components from @postkit/astro/components/*
  • React bridges from @postkit/astro/react

Troubleshooting

  • Missing components: pass postkitAstroComponents to the rendered MDX or content collection.
  • Missing directive transforms: create MDX options with createPostkitAstroMdxOptions().
  • Chakra context errors in islands: configure chakraSystem with a module that default-exports the site's SystemContext.
  • Unexpected client JavaScript: check the hydration policy before wrapping static components in a site-owned client island.

See the @postkit/react guide for the shared component, declaration, and theming APIs. The complete Astro example is built and inspected in CI.