nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Preset support tracker

Open pi0 opened this issue 11 months ago • 12 comments

This issue is a unified tracker for requested deployment presets.

  • Please upvote 👍🏼 original (closed) issues to support and comment if you would like to work on them
  • Please be patient with WIP items. PRs often need redo and other works for long-term maintenance
  • Please comment (here) if you would like to propose a new deployment preset (new platform) support
Name Original Issue Documentation Link Draft PR
Spin / Fermyon Cloud #2844 Docs -
appwrite.io #2778 Docs -
open-runtimes #2449 Docs -
azure -app -service #2231 - -
akash network #1877 Docs -
wasmer edge #1866 Docs -
Plesk #1819 - -
Spiderfire #1781 - -
azion #1414 Docs -
docker #54 - -
fastly edge #1426 Docs -
scaleway functions #1261 Docs -
edgegap #156 Docs -
AWS Lambda behind Load Balancer (ALB) #2072 - #2914
coolify #2762 - #2767
AWS CDK #1387 - #240 (stalled)
AWS lambda edge #79 Docs #1557 (stalled)
SST #133 - #2236 -
Clever Cloud - Docs -
Tencent’s EdgeOne #3234 Docs -
Bare - Docs -
Val.town discord Docs -
Tencent EdgOne Pages discord https://pages.edgeone.ai/ -

pi0 avatar Jan 07 '25 15:01 pi0

Great list @pi0 ! Should we add something like cloudflare-modules-static to leverage the new static assets ?

Just deployed something with cloudflare-pages-static, which is great for some use case where static files are needed (ie: new Worker(new URL('file.js', import.meta.url).href), { type:module }))

Hebilicious avatar Jan 16 '25 10:01 Hebilicious

It is already supported with latest compatibility date.

This tracker is mainly for new platforms not adding features.

pi0 avatar Jan 16 '25 10:01 pi0

I would be happy to help/work on the Docker preset. In fact I've been developing/using these two dockerfiles for the last couple of years now, both for Nuxt and Nitro. One based on bun and the other based on pnpm, both supporting caching for subsequent builds. Do I understand it correctly that is mostly a topic on adding the dockerfile and docker-compose to the project if the docker preset is used?

Other presets I might be helpful with:

  • coolify this can be both based on docker and nixpacks, depending on the project/deployment requirements.
  • open-runtimes they added a few meta-frameworks as presets, although they are all proxyed via micro if I understand it correctly
  • appwrite uses open-runtimes under the hood
  • plesk

sandros94 avatar Jan 16 '25 11:01 sandros94

It is already supported with latest compatibility date.

This tracker is mainly for new platforms not adding features.

Should I open another issue since cloudflare is an existing platform, and this would be a new preset for an existing platform?

AFAIK the only cloudflare preset that supports nuxt generate is cloudflare-pages-static (https://github.com/nitrojs/nitro/blob/v2/src/presets/cloudflare/preset.ts)

I'm talking about building a static website (ie nuxt generate, no js entrypoint etc), and deploying it to cloudflare workers (not pages) with the new static assets features.

It's possible to do this with a custom nitro preset, but I would like the option to use cloudflare-module-static or cloudlare-worker-static directly.

All these different options are confusing and I'd be happy to contribute more docs (cloudflare-pages-static is not documented)

Edit : After carefully inspecting the unminified bundle, and playing with the options, it appears the current behaviour for cloudflare_module will use env.ASSETS to serve static assets according to the routeRules settings (ssr, prerender, swr ...) Would be nice to have the exact behaviour documented though, or to have the option to have a preset that doesn't use nitro.localFetch and just env.ASSETS() with "not_found_handling": "single-page-application" (For Nuxt apps withtout server runtime like SPAs)

Hebilicious avatar Jan 19 '25 07:01 Hebilicious

It is already supported with latest compatibility date. This tracker is mainly for new platforms not adding features.

Should I open another issue since cloudflare is an existing platform, and this would be a new preset for an existing platform?

AFAIK the only cloudflare preset that supports nuxt generate is cloudflare-pages-static (https://github.com/nitrojs/nitro/blob/v2/src/presets/cloudflare/preset.ts)

I'm talking about building a static website (ie nuxt generate, no js entrypoint etc), and deploying it to cloudflare workers (not pages) with the new static assets features.

It's possible to do this with a custom nitro preset, but I would like the option to use cloudflare-module-static or cloudlare-worker-static directly.

All these different options are confusing and I'd be happy to contribute more docs (cloudflare-pages-static is not documented)

Edit : After carefully inspecting the unminified bundle, and playing with the options, it appears the current behaviour for cloudflare_module will use env.ASSETS to serve static assets according to the routeRules settings (ssr, prerender, swr ...) Would be nice to have the exact behaviour documented though, or to have the option to have a preset that doesn't use nitro.localFetch and just env.ASSETS() with "not_found_handling": "single-page-application" (For Nuxt apps withtout server runtime like SPAs)

Hello, any news for a cloudflare-module-static preset ? thanks!

GreyXor avatar May 12 '25 10:05 GreyXor

@GreyXor if you use cloudflare-module, and enable prerendering, it should work. You'll have to play with the route rules settings and look at what works and doesn't.

Hebilicious avatar May 13 '25 19:05 Hebilicious

@GreyXor if you use cloudflare-module, and enable prerendering, it should work. You'll have to play with the route rules settings and look at what works and doesn't.

Hello @Hebilicious, With nuxt generate (so it's pre-rendering enabled), cloudflare-module preset and compatibility date of 2025-06-06. That's actually not generate index.html in the dist directory. Therefore I cannot use it as static-asset in Cloudflare Worker. Do you have an idea? thanks!

GreyXor avatar Aug 19 '25 11:08 GreyXor

@GreyXor I'm having some success with v2.12.6 and the following settings :

In your nuxt/nitro config :

routeRules: {
	"/": { ssr: false, static: true, prerender: true }
}
nitro: { preset: "cloudflare-module", minify: false }

In wrangler.jsonc :

{
	"$schema": "https://unpkg.com/wrangler@latest/config-schema.json",
	"main": "./.output/server/index.mjs",
	"compatibility_date": "2025-08-07",
	"compatibility_flags": ["nodejs_compat"],
	"assets": {
		"binding": "ASSETS",
		"directory": "./.output/public/"
	}
}

Then run nuxt build ...

If you inspect .output/server/chunks/nitro/nitro.mjs, you should find something like this at the bottom of the file

const cloudflareModule = createHandler({
  fetch(request, env, context, url) {
    if (env.ASSETS && isPublicAssetURL(url.pathname)) {
      return env.ASSETS.fetch(request);
    }
  }
});

and you should also find a .output/public/index.html

Hebilicious avatar Sep 12 '25 05:09 Hebilicious

Thanks @Hebilicious! But that's not using the generate pre-renderto have the full SSR and it's not really easy to use. I would like same preset as cloudflare-page-static. More context here: https://nuxt.com/docs/4.x/getting-started/deployment#static-hosting And I also need the 200.html and 404.html

Hi @pi0, as you can see for Cloudflare workers Static Assets-only it's not straightforward to setup. Could we have a cloudflare-module-static preset ? To let us generate prerendered (SSG+SSR) pure static nuxt for Cloudflare Workers Static Assets. Thanks everyone

GreyXor avatar Sep 13 '25 08:09 GreyXor

Thanks @Hebilicious! But that's not using the generate pre-renderto have the full SSR and it's not really easy to use. I would like same preset as cloudflare-page-static. More context here: https://nuxt.com/docs/4.x/getting-started/deployment#static-hosting And I also need the 200.html and 404.html

Hi @pi0, as you can see for Cloudflare workers Static Assets-only it's not straightforward to setup. Could we have a cloudflare-module-static preset ? To let us generate prerendered (SSG+SSR) pure static nuxt for Cloudflare Workers Static Assets. Thanks everyone

I've been advocating for deprecating and removing Nuxt generate as it's making people confused. Generate does build and configure prerendering for you. But if you configure the pre-render with routeRules, you achieve the same outcome.

I do think that adding a cloudflare static would be interesting. But I think documenting the proper use of routeRules is fine, since it's a more flexible API, and would work if you have an API route (like an internal Telemetry/analytics endpoint)

Hebilicious avatar Sep 13 '25 11:09 Hebilicious

Sure, as long we can still have a pure static SSR+SSG pre-rendered experience, i'm happy :) I also prefer a "flexible API" over multiple "sub-commands". Thanks for your input, very informative.

GreyXor avatar Sep 13 '25 20:09 GreyXor

Sure, as long we can still have a pure static SSR+SSG pre-rendered experience, i'm happy :) I also prefer a "flexible API" over multiple "sub-commands". Thanks for your input, very informative.

If you want hydration and pre-rendering for all pages, this should do the trick :

const routeRules = { "/**": { ssr: true, prerender: true } }

Give it a try and let me know.

For custom 404 you might need to modify your wrangler.jsonc https://developers.cloudflare.com/workers/static-assets/routing/static-site-generation/#custom-404-pages

There's definitely room for improvement for routeRules documentation.

Hebilicious avatar Sep 14 '25 09:09 Hebilicious