#How to make Cloudflare websocket work with astro dev?

3 messages · Page 1 of 1 (latest)

sleek hazel
#

It currently only works with wrangler dev

drowsy forgeBOT
#

Hi @sleek hazel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the provided documentation, there is no built-in way to make Cloudflare-specific modules like cloudflare:sockets work with the standard astro dev command.

The knowledge sources explicitly state that Cloudflare namespaced packages do not work locally without using Wrangler dev mode [Cloudflare module support].

To use these features locally, you must update your package.json preview script and run your application through Wrangler:

  • For Workers: "preview": "wrangler dev"
  • For Pages: "preview": "wrangler pages dev ./dist"

Using Wrangler provides access to Cloudflare-specific features such as bindings, environment variables, and the cf object [Preview with Wrangler].

The documentation notes that getting hot reloading to work between the Astro dev server and Wrangler might require custom setup, and it suggests checking community examples for potential workarounds [Preview with Wrangler].

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: