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

@quantajs/astro

v3.0.0

Published

Astro integration for QuantaJS: one store shared by React, Vue and Svelte islands, a container per request, and server state that reaches the islands.

Readme

@quantajs/astro

CI npm

QuantaJS for Astro. One store, shared by every island whatever its framework, with state loaded on the server reaching the islands in the browser.

Documentation · Example app · Changelog

  • Each request gets its own container. Pages, middleware and islands rendered on the server all resolve stores against it, so concurrent requests never share state.
  • Server state reaches the islands. The request's state is written into the page and applied before any island hydrates, so islands start from what the server rendered.
  • Islands share one store. React, Vue and Svelte islands on one page read and change the same state, through their own bindings.

Install

npm install @quantajs/core @quantajs/astro

Add the bindings for the frameworks your islands use: @quantajs/react, @quantajs/vue or @quantajs/svelte.

// astro.config.mjs
import { defineConfig } from 'astro/config';
import quanta from '@quantajs/astro';

export default defineConfig({
    integrations: [quanta()],
});

Usage

Define stores once, in plain TypeScript:

// src/stores/cart.ts
import { defineStore } from '@quantajs/core';

export const useCart = defineStore('cart', {
    state: () => ({ user: '', items: [] as string[] }),
    actions: {
        async load(user: string) {
            this.user = user;
            this.items = await fetchItems(user);
        },
        add(item: string) {
            this.items.push(item);
        },
    },
});

Load state in a page's frontmatter. Calling the store without a container uses the current request's; it is also available as Astro.locals.quanta.

---
// src/pages/cart.astro
import { useCart } from '../stores/cart';
import ReactCart from '../components/ReactCart';
import VueCount from '../components/VueCount.vue';

await useCart().load(Astro.url.searchParams.get('user') ?? 'guest');
---

<html>
    <head><title>Cart</title></head>
    <body>
        <ReactCart client:load />
        <VueCount client:load />
    </body>
</html>

Islands use the binding for their framework, with no provider or container:

// src/components/ReactCart.tsx
import { useQuantaActions, useQuantaValue } from '@quantajs/react';
import { useCart } from '../stores/cart';

export default function ReactCart() {
    const items = useQuantaValue(useCart, (s) => s.items);
    const cart = useQuantaActions(useCart);
    return (
        <button onClick={() => cart.add('tea')}>{items.length} items</button>
    );
}

A change made in one island shows in every other island on the page, React, Vue or Svelte.

How it works

  • The integration adds middleware that runs first. It creates a container for the request, stores it in Astro.locals.quanta, and makes it the default container while the request renders, using Node's AsyncLocalStorage.
  • When the page's </head> is sent, the middleware writes the container's state into a script. By then the page's frontmatter has run. The state is serialised with devalue, so Date, Map and Set survive and no value can break out of the script. The container is disposed once the page has been sent.
  • In the browser, a script that Astro loads before hydrating any island applies that state to the default container, which every island resolves against. With view transitions, each new page's state is applied as it arrives.

Things to know

  • Load state before the page's <head> is sent: in middleware, or in the frontmatter of the page or its layout. A change made while rendering the page body, after the head, is not in the snapshot.
  • The server needs AsyncLocalStorage. Node, Deno and Bun have it; on Cloudflare, enable nodejs_compat.
  • Prerendered pages carry the state from build time.
  • API routes and other non-HTML responses get a container too, and are passed through unchanged.

License

MIT