cd /news/ai-infrastructure/building-with-bun-and-cosmic-the-fas… · home topics ai-infrastructure article
[ARTICLE · art-18353] src=dev.to pub= topic=ai-infrastructure verified=true sentiment=↑ positive

Building with Bun and Cosmic: The Fastest JavaScript Stack in 2026

Bun v1.3, the JavaScript runtime acquired by Anthropic in December 2025, now delivers sub-100ms content delivery when paired with Cosmic's REST API, creating a full-stack JavaScript stack optimized for speed at every layer. The combination eliminates traditional bottlenecks by running TypeScript directly without compilation, installing packages in roughly 200ms on a warm cache, and serving content through a built-in HTTP server that outperforms Express on Node.js. Bun's ongoing rewrite of core internals in Rust and its integration with Anthropic's Claude Code and Agent SDK signal a long-term commitment to performance as both a runtime and AI infrastructure foundation.

read3 min publishedMay 30, 2026

Originally published on the Cosmic blog.

Bun v1.3 is the fastest JavaScript runtime you can use right now. Cosmic's REST API returns content in under 100ms. Put them together and you get a full-stack setup that's faster at every layer: cold starts, package installation, HTTP requests, and content delivery.

This is a practical tutorial. You'll set up a Bun project, pull content from Cosmic using the JavaScript SDK, and see why this combination is the right default for JavaScript developers building content-heavy apps in 2026.

Bun is also actively rewriting core internals in Rust, doubling down on raw performance and memory safety. This isn't just an optimization story: it signals a long-term commitment to speed as a first-class priority.

Bun started as a fast alternative to Node.js, but in December 2025 it was acquired by Anthropic, which is now betting on it as the runtime infrastructure powering Claude Code and the Claude Agent SDK. That acquisition signals something: the fastest JavaScript runtime is also where serious AI tooling is heading.

Bun is built on JavaScriptCore (the engine that powers Safari) and written in Zig. It ships as a single binary that includes a runtime, package manager, bundler, and test runner. In practice this means:

Bun v1.3 (released October 2025) added zero-config frontend development, a unified SQL API, and a built-in Redis client. As of v1.3.14, it includes a built-in image processing API, HTTP/3 support, and 7x faster warm installs. It's not a prototype anymore: Vercel added native Bun runtime support in October 2025.

Cosmic is an API-first headless CMS. Your content lives in Cosmic's CDN-backed infrastructure and is available via a REST API and JavaScript SDK.

Key performance characteristics:

For Bun specifically, this matters because Bun's fast startup time is only useful if your data layer doesn't become the bottleneck. Cosmic's cached REST API is fast enough that it doesn't.

bun init

Bun creates package.json

, tsconfig.json

, and an entry point. No additional configuration needed.

bun add @cosmicjs/sdk

Installs in roughly 200ms on a warm cache.

// lib/cosmic.ts
import { createBucketClient } from '@cosmicjs/sdk'

export const cosmic = createBucketClient({
  bucketSlug: process.env.COSMIC_BUCKET_SLUG!,
  readKey: process.env.COSMIC_READ_KEY!,
})

That's the entire setup. No ORM, no connection pool.

import { cosmic } from './lib/cosmic'

const { objects: posts } = await cosmic.objects
  .find({ type: 'posts' })
  .props(['title', 'slug', 'metadata'])

console.log(posts)
bun run index.ts

No compilation step. Bun runs TypeScript directly. On a warm cache the Cosmic API call returns in under 100ms.

Bun has a built-in HTTP server (Bun.serve

) that's significantly faster than Express on Node.js:

import { cosmic } from './lib/cosmic'

Bun.serve({
  port: 3000,
  routes: {
    '/api/posts': async () => {
      const { objects } = await cosmic.objects
        .find({ type: 'posts' })
        .props(['title', 'slug', 'metadata'])
      return Response.json(objects)
    },
  },
})

No framework, no middleware setup, no boilerplate.

None of these numbers require you to do anything special. Install Bun, use @cosmicjs/sdk

, and you get them automatically.

A few things converged to make this stack compelling right now:

The practical result: a Bun + Cosmic stack is faster to set up, faster to install, faster to run, and delivers fast content. There's no trade-off to evaluate here.

Sign up for Cosmic free (no credit card required), create a bucket, add a content type, and follow the setup steps above. You'll have a working content API in under 10 minutes.

Want to talk through your specific use case? Book a 30-minute intro with Tony.

── more in #ai-infrastructure 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-with-bun-an…] indexed:0 read:3min 2026-05-30 ·