← English news
Priority 4/5

Vercel Functions Now Support Bun.serve Entrypoints and Native WebSocket Handlers

Vercel has added support for using Bun.serve as a direct entrypoint in Vercel Functions, allowing developers to deploy native WebSockets and server.ts configurations without external frameworks.

Vercel Functions Now Support Bun.serve Entrypoints and Native WebSocket Handlers

Vercel has introduced native support for Bun.serve as an entrypoint for Vercel Functions utilizing the Bun runtime. This update enables developers to deploy server logic directly from a root-level server.ts file, maintaining consistency between local development and production environments without the need for additional web framework wrappers. With this integration, developers can map static, dynamic, and wildcard routes natively. The feature also enables native WebSocket support on Vercel Functions by allowing developers to initiate connection upgrades using the server.upgrade method directly within the fetch handler, resolving previous limitations on real-time event handling. Adopting this feature requires specifying bunVersion as 1.x or higher in the vercel.json configuration file and applying the Bun framework preset. When migrating existing functions, codebases must be adjusted to align routing structures and entrypoint filenames with the Bun.serve specifications.

Primary source

Open Vercel Changelog ↗

This article summarizes the source. Check the original for full details and conditions.

Comparison

AspectBefore / AlternativeAfter / This
Entrypoint ConfigurationRequired framework adapters or wrapper configurations to route requestsDirect deployment of native server.ts using Bun.serve()
WebSocket ImplementationRestricted or required external workarounds to handle persistent connectionsNative support via server.upgrade inside the fetch handler
Routing ManagementManaged through framework-specific routing rules or Vercel JSON routingMapped natively via Bun's path and wildcard handling in server.ts

Action Checklist

  1. Configure vercel.json to target bunVersion 1.x or higher Ensure your project configuration explicitly defines a compatible Bun runtime version.
  2. Set up a server.ts file at the root of your project Define the export default Bun.serve block including fetch and optional websocket handlers.
  3. Enable the Bun framework preset in your Vercel project settings This preset allows Vercel to automatically detect and build the Bun.serve entrypoint.