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

@vizejs/data

v0.818.0

Published

Typed SSR data resource foundations for Vize applications

Readme

@vizejs/data

Typed SSR data resource foundations for Vize applications.

This package is released on npm as @vizejs/data; its resource and adapter contracts remain experimental throughout the Vize alpha line.

<script setup lang="ts">
import { createDataClient, defineDataResource } from "@vizejs/data";

const articleResource = defineDataResource({
  key: "article.byId",
  source: "./ArticleView.vue",
  async loader({ input }: { input: { id: string } }) {
    return { id: input.id, title: "Hello Vize" };
  },
});

const data = createDataClient();
const article = await data.load(
  articleResource,
  { id: "intro" },
  {
    retries: 2,
    retryDelayMs: ({ attempt }) => attempt * 100,
    deadlineMs: 1500,
  },
);
</script>

<template>
  <article v-if="article.status === 'success'">
    {{ article.data.title }}
  </article>
</template>

Server renderers can call serializeDataSnapshot(data) and hydrate the client with hydrateDataClient(snapshot). Hydrated success entries satisfy the first client load without issuing duplicate network work; policy: "replace" opts back into a fresh request. A failed fetch serializes as its name, message, and status: the decoded error body stays on the server unless serializeError returns it.

Cache, races, and optimistic work

The client supports deduplication, cache-first reads, explicit revalidation, replacement, and stale-while-revalidate. Each request key has latest-result custody: an older response may resolve to its caller, but cannot overwrite a newer cache entry. replace aborts the previous request, while cancel exposes route- or scope-owned cancellation. Optimistic updates return a guarded rollback; the rollback refuses to overwrite data that a later request has already committed.

const rollback = data.optimistic(articleResource, { id: "intro" }, (article) => ({
  ...article,
  title: "Draft title",
}));

const stale = await data.load(
  articleResource,
  { id: "intro" },
  {
    policy: "stale-while-revalidate",
  },
);

Runtime adapters

createFetchDataResource adapts typed HTTP endpoints, createStreamDataResource reduces an abort-aware async iterable, and hydrateDataClientFromStream restores incremental SSR snapshots. None of them reads browser globals during module evaluation. createDataTestAdapter supplies a deterministic response queue and records every load context for race, retry, and cancellation tests. Resources can return an explicit unsupported reason from supports before their loader runs.