Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

A developer's laptop showing Bun 1.4 code editor with a terminal window, surrounded by coffee and notes…
Open SourceScore: 75

Bun 1.4's Bun.WebView: Build a Shot-Scraper-Style JSON API for Claude Code

Bun 1.4's Bun.WebView enables a 192-256MB browser automation JSON API (shot-scraper style). Use it to give Claude Code web scraping and JS execution without heavy Playwright overhead.

·1d ago·3 min read··24 views·AI-Generated·Report error
Share:
Source: simonwillison.netvia simon_willison, devto_claudecodeWidely Reported
How do I use Bun 1.4's Bun.WebView to build a JSON API for browser automation in Claude Code?

Bun 1.4's Bun.WebView enables browser automation via WebKit or CDP. Simon Willison built a shot-scraper-style JSON API that loads pages and executes JavaScript, running in 192-256MB. Use it to add web scraping or rendering capabilities to your Claude Code workflows with minimal overhead.

TL;DR

Bun 1.4's Bun.WebView lets you build a browser automation JSON API—like shot-scraper—that runs Chrome in just 192-256MB, perfect for Claude Code tasks.

Key Takeaways

What Changed

In the next version of Bun Bun.WebView programmatically ...

Bun 1.4 dropped today, and it's a big one. The long-awaited Rust rewrite is here, but buried under a mountain of new features: Bun.Image, Bun.markdown, Bun.cron(), bun run --parallel, and more. For Claude Code users, the standout is Bun.WebView — first-class browser automation built into Bun's core, using either macOS WebKit or a local Chromium via the Chrome DevTools Protocol (CDP).

Simon Willison immediately put it to the test: he had Claude Code for web build a prototype JSON API inspired by his shot-scraper javascript tool. The result? A TypeScript server that loads a page, executes JavaScript against it, and returns the result — all in a 192MB-256MB container.

What It Means For You

If you've ever wanted Claude Code to scrape dynamic pages, render SPAs, or run browser-based assertions, you've probably reached for Playwright or Puppeteer. Those are heavy — a full Chromium instance can eat 500MB+ easily. Bun.WebView's approach cuts that dramatically:

  • 192MB-256MB for a full Chrome against complex pages (tested with cgroups)
  • Native CDP support — no extra driver or wrapper needed
  • WebKit option on macOS for lighter, faster local runs
  • Built into Bun core — no npm install, no version mismatch headaches

This means you can run a browser automation service in a tiny container, right next to your Claude Code agent, without blowing up your infrastructure costs.

Try It Now

Here's how to get started:

  1. Install Bun 1.4: curl -fsSL https://bun.sh/install | bash (or brew install bun)

  2. Clone Simon's prototype for a working reference:

    git clone https://github.com/simonw/research/tree/main/bun-webview-json-api
    cd bun-webview-json-api
    bun install
    
  3. Build your own minimal server — the core pattern is simple:

    import { WebView } from "bun";
    
    const server = Bun.serve({
      port: 3000,
      async fetch(req) {
        const url = new URL(req.url);
        if (url.pathname === "/scrape") {
          const target = url.searchParams.get("url");
          const script = url.searchParams.get("script") || "return document.title";
          const wv = new WebView({ url: target });
          const result = await wv.evaluate(script);
          return Response.json({ result });
        }
        return new Response("Not found", { status: 404 });
      },
    });
    
  4. Wire it into Claude Code — add an MCP server or use a claude CLI call:

    claude -p "Scrape https://example.com and extract all h2 headings" --tool "curl http://localhost:3000/scrape?url=https://example.com&script=return Array.from(document.querySelectorAll('h2')).map(h=>h.textContent)"
    
  5. Optimize for your use case:

    • Use WebKit on macOS for dev/testing (faster startup)
    • Use Chromium in production for full compatibility
    • Set a memory limit in your container (start at 256MB, adjust down)

Pro tip: Combine with Bun.cron() to schedule periodic scrapes that feed data back to Claude Code for analysis — all in one Bun process.

Why This Matters for Claude Code

Claude Code excels at reasoning and code generation, but it can't click buttons or render JavaScript. Bun.WebView gives you a lightweight bridge to the browser that's cheap enough to run as a sidecar service. No more spinning up a 1GB Playwright container just to check if a page loads — a 192MB Bun service does it.

Simon's prototype is just the start. Imagine:

  • Visual regression testing — capture screenshots, compare with Claude Code's vision
  • Dynamic form filling — automate complex multi-step web flows
  • SPA scraping — extract data from React/Vue apps that need JS execution

Bun 1.4 makes this trivial. Try it today.


Source: simonwillison.net

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

**What should Claude Code users do differently?** First, stop defaulting to Playwright for browser automation. Bun.WebView's CDP support gives you the same Chrome control with a fraction of the memory footprint. If you're running Claude Code in a CI pipeline or a constrained container, this is a game-changer — you can now afford to run browser checks on every commit without ballooning your infrastructure bill. Second, adopt Simon's pattern: have Claude Code generate your automation server, then call it via HTTP. This keeps your agent's context clean (no browser driver noise) and makes the service reusable across multiple sessions. Start with his prototype, customize the API endpoints to your needs, and you'll have a production-ready scraping service in under an hour. Finally, experiment with the full Bun 1.4 feature set. Pair `Bun.WebView` with `Bun.cron()` for scheduled scraping, or `bun run --parallel` to run multiple scrape jobs concurrently. The Rust rewrite brings real performance gains — 5x less idle CPU, 35% less memory, 50% faster startup — so you can run this service alongside Claude Code without worrying about resource contention.
This story is part of
Hugging Face Becomes the Neutral Ground Where Google and Anthropic's Agent Protocol War Converges
As Claude Code's MCP dominance threatens Google Cloud, Hugging Face's unique position as partner to both players creates an unexpected convergence zone
Compare side-by-side
Claude Code vs Bun.WebView
Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all