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

@web-ai-sdk/writer

v0.6.0

Published

Building block for the Web's Built-in Writer API (Chrome)

Readme

@web-ai-sdk/writer

Building block for the Web's Built-in Writer API. Generates new content from a writing task with session reuse, streaming, and opt-in result caching.

Docs: https://web-ai-sdk.dev/docs/guides/writer/ · React: useWriter

Status

The Writer API is in a developer trial (origin trial) in Chrome 137 to 148, behind chrome://flags/#writer-api-for-gemini-nano on localhost (chrome://flags/#optimization-guide-on-device-model must also be enabled). In Edge it's a developer preview in Canary/Dev 138+ behind "Writer API for Phi mini". On any other browser this library is a no-op for the React hook (it stays in "unavailable"). The vanilla write() throws WriterUnavailableError so callers can branch explicitly.

Install

pnpm add @web-ai-sdk/writer
# or: npm i @web-ai-sdk/writer / bun add @web-ai-sdk/writer

The React adapter ships as a subpath export, with no extra install. react is a peer dependency only when you import the /react entry.

Vanilla TypeScript / DOM

import { write } from "@web-ai-sdk/writer";

const result = await write({
  input: "An inquiry to my bank about how to enable wire transfers.",
  context: "I'm a longstanding customer.",
  tone: "formal",
  length: "medium",
  onUpdate: (text) => console.log("partial", text),
});

console.log(result.output, result.cached);

result.output is the generated text (trimmed), or null when the input is empty. result.cached tells you whether the response came from the cache without invoking the model.

React

import { useWriter } from "@web-ai-sdk/writer/react";

export function Draft({ task }: { task: string }) {
  const { status, output } = useWriter({ input: task, tone: "casual" });

  if (status === "unavailable") return null;
  if (status === "loading") return <p>Drafting…</p>;
  return <article>{output}</article>;
}

State machine: idle | loading | streaming | done | unavailable. output is the latest text (grows during streaming). fromCache is true when the result came back without invoking the model.

API

write(options): Promise<WriteResult>

interface WriteOptions {
  input: string;                  // the writing task / prompt
  context?: string;               // per-call background info
  language?: string;              // BCP-47; drives input/output hints when supported
  supportedLanguages?: readonly string[]; // default ["en", "es", "ja"]
  tone?: "formal" | "neutral" | "casual";  // default "neutral"
  format?: "markdown" | "plain-text";       // default "markdown"
  length?: "short" | "medium" | "long";     // default "short"
  sharedContext?: string;
  monitor?: (m: CreateMonitor) => void;
  cache?: "session" | "local" | { get, set };
  cacheKey?: string;
  onUpdate?: (text: string) => void; // cumulative buffer, not deltas
  signal?: AbortSignal;
}

interface WriteResult {
  output: string | null;
  cached: boolean;
}

isAvailable(): boolean

Feature-detect helper.

checkAvailability(options?): Promise<WriterAvailability | null>

Forwards to the spec's availability() call. Returns null if the global is missing or the call throws.

Cache controls

import {
  clearWriterSessions,    // drop every cached writer session
  clearWriterSession,     // drop one cached session by create-options
  configureWriterCache,   // change the LRU cap (default 8)
} from "@web-ai-sdk/writer";

The internal session cache is LRU-bounded (default 8). Evicted sessions have their destroy() invoked when present.

Output normalization

The wrapper trims leading/trailing whitespace only, so internal markdown formatting and line breaks the model produces stay intact. Anything beyond that is the consumer's concern.

Language support beyond en/es/ja

The Writer accepts expectedInputLanguages / expectedContextLanguages / outputLanguage for ["en", "es", "ja"] by default. Pass any other language and the library omits those hints; steer output via sharedContext instead, or pass your own supportedLanguages when more land.

License

MIT © Beto Muniz