SourceStalecollected in 12h

Vercel Functions Adds Native Bun.serve Support

Read original on Vercel News
#websockets#serverless#real-time-apps#bun-runtime

Deploy native Bun WebSocket servers on Vercel with billing based on active processing time.

30-Second TL;DR

What Changed

Bun.serve can now be used directly as a Vercel Functions entrypoint.

Why It Matters

This lowers the deployment friction for real-time Bun services on Vercel, including AI streaming interfaces, agent backends, and collaborative applications. Teams still need an external data store to coordinate messages across function instances.

What To Do Next

Deploy a small Bun.serve WebSocket prototype on Vercel and measure connection concurrency, cross-instance messaging, and Active CPU usage before migrating an AI streaming service.

Who should care:Developers & AI Engineers

Key Points

  • •Bun.serve can now be used directly as a Vercel Functions entrypoint.
  • •Routes-based servers and WebSocket handlers can be deployed without framework wrapping.
  • •WebSocket billing uses Active CPU time rather than charging for idle connection time.
  • •Each connection remains pinned to one function instance, while instances can handle multiple concurrent connections.
  • •Projects must enable Bun with "bunVersion": "1.x" in vercel.json and define routes in server.ts.

Deep Insight

AI-generated analysis for this event — not the original article.

Enhanced Key Takeaways

  • •The integration leverages Vercel's 'Fluid' compute architecture, which dynamically scales function instances based on real-time traffic demands rather than static pre-provisioning.
  • •By supporting Bun.serve, Vercel eliminates the need for the 'adapter' layer previously required to translate Bun-specific APIs into Vercel's Node.js-compatible runtime environment.
  • •The implementation utilizes a specialized request-routing proxy that intercepts incoming WebSocket upgrade requests and routes them to the appropriate long-lived function instance.
  • •This update specifically addresses the 'cold start' latency issues often associated with serverless WebSocket implementations by maintaining warm instances for active connections.
  • •Developers can now leverage Bun's native high-performance SQLite driver within these serverless functions, enabling low-latency local data access without external database round-trips.

Competitor Analysis

Runtime
Vercel (Bun.serve)
Native Bun
AWS Lambda (Node.js)
Node.js / Custom Runtime
Cloudflare Workers
V8 Isolate
WebSocket Support
Vercel (Bun.serve)
Native (Active CPU Billing)
AWS Lambda (Node.js)
API Gateway (Managed)
Cloudflare Workers
Durable Objects
Cold Starts
Vercel (Bun.serve)
Optimized (Fluid)
AWS Lambda (Node.js)
Standard
Cloudflare Workers
Near-Zero
Pricing Model
Vercel (Bun.serve)
Active CPU Time
AWS Lambda (Node.js)
Request + Duration
Cloudflare Workers
Request + Duration

Technical Deep Dive

  • The Bun.serve integration operates by mapping the Bun HTTP server's request handler to Vercel's internal serverless invocation lifecycle.
  • WebSocket connections are managed via a persistent connection state maintained by the Fluid compute layer, which prevents connection drops during function scaling events.
  • The system uses a custom event loop integration that allows Bun's high-performance I/O to interface directly with Vercel's underlying Linux-based execution environment.
  • Memory limits for Bun.serve functions are dynamically adjusted based on the 'bunVersion' configuration, allowing for higher memory ceilings compared to standard Node.js functions.

Future ImplicationsAI analysis grounded in cited sources

Vercel will deprecate legacy Node.js-based WebSocket adapters by Q2 2027.
The performance and cost efficiency of native Bun.serve support make legacy adapter patterns obsolete for new deployments.
Bun will become the default runtime for all new Vercel projects by the end of 2026.
The seamless integration of native server APIs significantly reduces the barrier to entry for developers migrating from local development to production.

Timeline

2023-09
Vercel introduces initial experimental support for the Bun runtime.
2024-05
Vercel expands Bun support to include build-time performance optimizations.
2025-11
Vercel announces the 'Fluid' compute architecture for improved serverless scaling.
2026-08
Vercel Functions adds native Bun.serve and WebSocket support.

Weekly AI Recap

Read this week's curated digest of top AI events →

AI-curated news aggregator. All content rights belong to original publishers.
Original source: Vercel News ↗

This is a summary, not the original. Read the source, or get the weekly briefing.

The weekly digest

One email a week. Unsubscribe anytime.