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

> Source: <https://dev.to/tonyspiro/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026-3ci2>
> Published: 2026-05-30 04:49:16+00:00

*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.

``` js
// 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.

``` js
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:

``` 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](https://app.cosmicjs.com/signup) (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](https://calendly.com/tonyspiro/cosmic-intro).
