{"slug": "building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026", "title": "Building with Bun and Cosmic: The Fastest JavaScript Stack in 2026", "summary": "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.", "body_md": "*Originally published on the Cosmic blog.*\n\nBun 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.\n\nThis 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.\n\nBun 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.\n\nBun 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.\n\nBun 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:\n\nBun 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.\n\nCosmic 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.\n\nKey performance characteristics:\n\nFor 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.\n\n```\nbun init\n```\n\nBun creates `package.json`\n\n, `tsconfig.json`\n\n, and an entry point. No additional configuration needed.\n\n```\nbun add @cosmicjs/sdk\n```\n\nInstalls in roughly 200ms on a warm cache.\n\n``` js\n// lib/cosmic.ts\nimport { createBucketClient } from '@cosmicjs/sdk'\n\nexport const cosmic = createBucketClient({\n  bucketSlug: process.env.COSMIC_BUCKET_SLUG!,\n  readKey: process.env.COSMIC_READ_KEY!,\n})\n```\n\nThat's the entire setup. No ORM, no connection pool.\n\n``` js\nimport { cosmic } from './lib/cosmic'\n\nconst { objects: posts } = await cosmic.objects\n  .find({ type: 'posts' })\n  .props(['title', 'slug', 'metadata'])\n\nconsole.log(posts)\nbun run index.ts\n```\n\nNo compilation step. Bun runs TypeScript directly. On a warm cache the Cosmic API call returns in under 100ms.\n\nBun has a built-in HTTP server (`Bun.serve`\n\n) that's significantly faster than Express on Node.js:\n\n``` js\nimport { cosmic } from './lib/cosmic'\n\nBun.serve({\n  port: 3000,\n  routes: {\n    '/api/posts': async () => {\n      const { objects } = await cosmic.objects\n        .find({ type: 'posts' })\n        .props(['title', 'slug', 'metadata'])\n      return Response.json(objects)\n    },\n  },\n})\n```\n\nNo framework, no middleware setup, no boilerplate.\n\nNone of these numbers require you to do anything special. Install Bun, use `@cosmicjs/sdk`\n\n, and you get them automatically.\n\nA few things converged to make this stack compelling right now:\n\nThe 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.\n\n[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.\n\nWant to talk through your specific use case? [Book a 30-minute intro with Tony](https://calendly.com/tonyspiro/cosmic-intro).", "url": "https://wpnews.pro/news/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026", "canonical_source": "https://dev.to/tonyspiro/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026-3ci2", "published_at": "2026-05-30 04:49:16+00:00", "updated_at": "2026-05-30 05:11:34.728712+00:00", "lang": "en", "topics": ["ai-infrastructure", "ai-tools", "ai-products", "ai-startups", "ai-agents"], "entities": ["Bun", "Cosmic", "Anthropic", "Claude Code", "Claude Agent SDK", "JavaScriptCore", "Zig", "Redis"], "alternates": {"html": "https://wpnews.pro/news/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026", "markdown": "https://wpnews.pro/news/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026.md", "text": "https://wpnews.pro/news/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026.txt", "jsonld": "https://wpnews.pro/news/building-with-bun-and-cosmic-the-fastest-javascript-stack-in-2026.jsonld"}}