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

@opencookie-dev/astro

v0.2.0

Published

Astro integration for the OpenCookie headless store

Readme

@opencookie-dev/astro

Thin Astro integration for OpenCookie. It delegates consent behavior to @opencookie-dev/core and delegates browser UI to your chosen OpenCookie adapter. It does not duplicate policy or decision logic.

Install and configure

Add the integration to astro.config.mjs and point it at a browser module owned by your application:

import { defineConfig } from "astro/config";
import openCookie from "@opencookie-dev/astro";

export default defineConfig({
  integrations: [
    openCookie({
      entrypoint: "/src/opencookie.client.ts",
    }),
  ],
});

The default page stage asks Astro to bundle the module and load it on every page, including pages with no hydrated island. A typical entrypoint imports the application's client and the vanilla adapter:

import { mountOpenCookie } from "@opencookie-dev/vanilla";

import { client } from "./opencookie.config.js";

mountOpenCookie({ client });

Importing @opencookie-dev/astro does not access window or document. The integration emits an import for Astro and Vite to resolve. It does not evaluate the browser entrypoint during a static build or an on-demand server render.

Framework islands

Use the matching OpenCookie framework package inside your React, Vue, or Svelte component. Then import that component directly into an .astro file and use Astro's client:load directive when immediate interaction is required:

---
import ConsentControls from "../components/ConsentControls.jsx";
---

<ConsentControls client:load />

If the OpenCookie entrypoint must run before framework hydration, configure stage: "before-hydration". Keep the default page stage when pages without a hydrated island must still run the entrypoint.

Server render with no hydrated component

createAstroServerBinding() reads only the external store's stable server snapshot. It does not subscribe and does not access browser globals:

---
import { createAstroServerBinding } from "@opencookie-dev/astro";
import { consentStore } from "../lib/opencookie.server.js";

const { snapshot } = createAstroServerBinding(consentStore);
---

<p data-consent-prompt={snapshot.runtime.consentEvaluation.prompt}>
  Consent preference status
</p>

Create request-specific mutable state when rendering on demand. Do not share a mutable consent client between visitors. Static Astro output receives the same deterministic server snapshot for every visitor, then the browser entrypoint loads the visitor's persisted decision.

OpenCookie is a technical tool, not legal advice. Your policy, configuration, and deployment remain your responsibility.

Astro references

All references were accessed on 2026-08-22.

The package is tested against Astro 7.2.4, the stable registry release observed on 2026-08-22.