Cloudflare 中文文档
Durable Objects
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Build a WebSocket server with WebSocket Hibernation

Build a WebSocket server using WebSocket Hibernation on Durable Objects and Workers.

This example is similar to the Build a WebSocket server example, but uses the WebSocket Hibernation API. The WebSocket Hibernation API should be preferred for WebSocket server applications built on Durable Objects, since it significantly decreases duration charge, and provides additional features that pair well with WebSocket applications. For more information, refer to Use Durable Objects with WebSockets.

Finally, configure your wrangler.toml file to include a Durable Object binding and migration based on the namespace and class name chosen previously.