
Tony Spiro
May 29, 2026

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. We covered what that means for JavaScript developers here: Why Bun Is Rewriting in Rust.
Why Bun in 2026
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:
- Install speed: Bun installs packages up to 25x faster than npm. With v1.3.14's global store, warm reinstalls are 7x faster again.
- Startup time: Cold start times are significantly lower than Node.js, particularly for TypeScript projects where Bun transpiles natively without a separate build step.
- Async/await performance: Bun v1.3.7 shipped 35% faster async/await. v1.3.6 brought 15% faster async/await on top of that.
- Built-in tooling: No tsconfig.json gymnastics, no separate transpiler, no test framework to install.
Bun v1.3 (released October 2025) added zero-config frontend development, a unified SQL API, and 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.
Why Cosmic as the Content Layer
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:
- Cached API requests are served from a global CDN. Sub-100ms response times in most regions.
- The JavaScript SDK () is typed and tree-shakeable.
- No CMS server to run, no database to provision. You write frontend code and fetch content.
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.
Setting Up the Stack
Prerequisites
- Bun installed ()
- A free Cosmic account at cosmicjs.com
Step 1: Create a Bun project
Bun creates , , and an entry point. No additional configuration needed.
Step 2: Install the Cosmic SDK
Installs in roughly 200ms on a warm cache. Compare that to on a slower connection.
Step 3: Create your Cosmic client
Create a file:
That's the entire setup. No additional configuration, no ORM, no connection pool.
Step 4: Fetch content
Run it:
No compilation step. Bun runs TypeScript directly. On a warm cache the Cosmic API call returns in under 100ms. The Bun process itself starts in single-digit milliseconds.
Building a Bun HTTP Server with Cosmic
Bun has a built-in HTTP server () that's significantly faster than Express on Node.js. Here's a complete content API server:
This is the complete server. No framework, no middleware setup, no boilerplate. Bun v1.3 added static routes support to which gives you method-specific route matching without any routing library.
Using Bun with Next.js and Cosmic
If you're building on Next.js, Bun works as a drop-in replacement for npm/Node.js:
In your Next.js app, create a data fetching utility:
Run the dev server with Bun:
Bun replaces Node.js as the process runner. Package installation with is substantially faster than , which matters in CI/CD pipelines and fresh deployments.
Performance Reality Check
Here's what you can actually expect from this stack:
Bun startup time: Bun starts a TypeScript file in ~5ms on modern hardware. Node.js + ts-node is typically 200-500ms. For serverless functions and edge deployments where cold starts matter, this gap is meaningful.
Cosmic cached API response: Under 100ms from most regions for cached content. Cosmic serves from a global CDN. Your blog post list loads fast because the content is already at the edge.
Bun package install: First install of a medium-sized project (say, Next.js + a few dependencies) takes 5-10 seconds with Bun vs 30-60 seconds with npm on the same machine.
vs /: Bun's bundler is written in Zig and significantly faster than JS-based bundlers for equivalent workloads.
None of these numbers require you to do anything special. Install Bun, use , and you get them automatically.
Environment Setup
Create a file in your project root:
Bun reads files natively without . No additional package needed.
Get your Cosmic credentials from your bucket settings at app.cosmicjs.com.
Why This Matters in 2026
A few things converged to make this stack compelling right now:
-
Bun joined Anthropic in December 2025. The runtime that powers Claude Code is the same one you can use for your projects. When Anthropic ships AI tooling, it'll be Bun-first.
-
Bun 1.3 added zero-config frontend support. You don't need Vite or webpack for most projects anymore. Bun does it.
-
Vercel added native Bun runtime support in October 2025. You can deploy Bun applications to the same infrastructure that serves millions of Next.js apps.
-
The Cosmic REST API is genuinely fast. Headless CMS performance varies widely. Cosmic's CDN-backed API returns cached content in under 100ms, which means the content layer doesn't offset the runtime gains you get from Bun.
The practical result: a Bun + Cosmic stack is faster to set up (no configuration), faster to install (no npm), faster to run (no Node.js overhead), and delivers fast content (CDN-backed REST API). There's no trade-off to evaluate here.
Get Started
The fastest path to a working Bun + Cosmic project:
- Sign up for Cosmic free — 1 bucket, 1,000 objects, no credit card required.
- Create a bucket, add a content type, add a few objects.
- and follow the setup steps above.
You'll have a working content API in under 10 minutes.
For teams building larger projects, Cosmic's paid plans start at $49/month (Builder) and scale up to $499/month (Business) for larger teams and object counts. Additional team members are $29/user/month. See full pricing.
Want to talk through your specific use case? Book a 30-minute intro with Tony.
Resources: Cosmic JavaScript SDK | Bun documentation | Bun blog
Continue Learning
Ready to get started?
Build your next project with Cosmic and start creating content faster.
No credit card required • Free forever


