#How to deploy to Cloudflare Workers Static Assets (SSG)

4 messages · Page 1 of 1 (latest)

fallow cradleBOT
#

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

#

To deploy a statically generated Nuxt site (SSG) to Cloudflare Workers (not Cloudflare Pages), you need to ensure that your build process actually generates the static assets (like index.html).

When you use the Nitro preset cloudflare_module, it is designed for server-side rendering (SSR) and dynamic API routes, not for static site generation. This preset outputs a worker script to handle requests dynamically, but it does not generate static HTML files like index.html for each route.

Why is index.html not generated?
The cloudflare_module preset is for SSR and API endpoints, not SSG. If you want to generate static assets, you should use the nuxi generate command, which will prerender your pages and output them to .output/public (or dist/ if you use the legacy SSG mode). This is the standard way to generate static files for static hosting in Nuxt. You can then upload these files to a static asset host or a KV store, but not directly as part of the worker bundle with the cloudflare_module preset.

How to deploy SSG to Cloudflare Workers?
The knowledge sources do not provide a direct, officially documented workflow for deploying SSG output as static assets via Cloudflare Workers (as opposed to Cloudflare Pages or KV). However, the standard SSG process is:

  1. Run nuxi generate to build your static site. This will output static HTML files (including index.html) in .output/public or dist/.
  2. Upload these static files to your desired static asset storage (such as Cloudflare R2 or KV).
  3. Use a Worker to serve these assets from storage.
#

Summary:

  • The cloudflare_module preset is for SSR, not SSG, so it does not generate index.html.
  • For SSG, use nuxi generate to produce static files.
  • Serving static assets via Workers requires a custom setup to fetch files from storage (like R2 or KV), which is not covered in detail in the provided knowledge sources.

If you want a fully static deployment, consider using Cloudflare Pages, which is designed for this use case and is supported by Nuxt Content out of the box.

If you need to combine static assets with Workers, you will need to manually upload your generated files to a storage backend and write a Worker to serve them, but the knowledge sources do not provide a step-by-step guide for this approach.

For more on SSG and static hosting in Nuxt, see Static Hosting and Prerendering. For Cloudflare Pages, see Cloudflare Pages Deployment.

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

#

@royal shadow Kapa.ai is still learning and improving, please let me know how I did by reacting below.