How to export and host a Godot 4 web game
Updated · 3 min read
To host a Godot 4 web game cleanly, choose the Compatibility renderer, decide early between Godot 4.3+'s single-threaded export (works anywhere) or multi-threaded export (requires COOP/COEP headers), compress your .pck assets, and deploy the exported folder to a host that serves WebAssembly with the right headers.
1. Pick the right renderer and thread mode in Godot 4
- Renderer: Always use Compatibility (OpenGL ES 3 / WebGL 2) for web exports. Forward+ and Mobile rely on Vulkan/WebGPU features that are not universally supported in browsers.
- Single-threaded vs. Multi-threaded (Godot 4.3+):
- Single-threaded (
Thread Supportunchecked): Does not requireSharedArrayBufferorCOOP/COEPheaders, so it works on GitHub Pages and embedded iframes out of the box—and avoids audio crackling bugs on some browsers. - Multi-threaded (
Thread Supportchecked): Faster for heavy physics/C++/GDExtension workloads, but requiresCross-Origin-Opener-Policy: same-originandCross-Origin-Embedder-Policy: require-corpheaders on your web host (see How to fix SharedArrayBuffer errors).
- Single-threaded (
2. Export your web bundle
- Open Project → Export → Add… → Web.
- Install the matching export templates if prompted.
- Export into an empty folder (for example
export/web/) withindex.htmlas the filename. - Test locally with a real HTTP server (opening
index.htmldirectly viafile://will fail due to CORS):
python3 -m http.server 8000 --directory export/web
(If you enabled Thread Support, use Godot's built-in Run in Browser button or Vite/Node with COOP/COEP headers locally.)
3. Keep your .pck and .wasm download fast
Godot 4 web exports ship a ~30–40 MB .wasm engine binary plus your .pck asset archive. To keep load times bearable:
- Compress textures: Use VRAM Compressed (WebP/Lossy) for large sprites and 3D textures instead of uncompressed PNGs.
- Use Ogg Vorbis for music and keep
.wavonly for short, low-latency sound effects. - Strip unused modules only if you're building custom export templates—for most indies, optimizing textures and audio gets 80% of the savings with zero engine rebuilds.
- Note on updates: Normally, changing one script rebuilds the
.pckand forces testers to re-download the entire archive. Hosts that use FastCDC content-defined chunking (like Pita) split the.pckand.wasminto cached chunks so small updates only transfer the bytes that actually changed.
4. Where to host your Godot 4 web export
- itch.io: Zip the contents of
export/web/(withindex.htmlat the root), upload as HTML5, and check SharedArrayBuffer support if you enabled Thread Support. - Cloudflare Pages: Deploy
export/web/viawrangler pages deploy export/weband add a_headersfile if using Thread Support. Watch Cloudflare's 25 MB single-file limit—a Godot 4.wasmbinary can exceed 25 MB! - Pita: Point
[client] artifact = "export/web"inpita.tomland runpita publish --to production(or let your coding agent run it). Pita supports builds up to 1 GiB on both Free ($0) and Basic ($14/mo) with no 25 MB per-file ceiling, configuresCOOP/COEPheaders automatically on an isolated game origin, and caches.wasm/.pckchunks via FastCDC so playtest updates load in seconds.
FAQ
Why does Cloudflare Pages reject my Godot 4 .wasm file?
Cloudflare Pages enforces a 25 MiB per-file limit, and a default Godot 4 web export's .wasm file is often 30–40 MiB uncompressed. You either need a custom stripped Godot export template, single-file hosting elsewhere (like itch.io or Pita), or R2/S3 with custom headers.
Why is audio silent when my Godot web game first loads?
Browsers block WebAudio until the user interacts with the page (click or keypress). Show a clean title screen or "Click to start" button before playing background music.