github nitrojs/nitro v2.4.0

latest releases: v2.10.4, v2.10.3, v2.10.2...
18 months ago

compare changes

⬆️ How to Upgrade?

If you are directly using Nitro, make sure to recreate lockfile as well in order to receive all UnJS ecosystem updates.

If you are using Nitro via Nuxt, simply use npx nuxi@latest upgrade --force.

⭐ What is new?

isr route rule

Vercel and Netlify route rules support a dedicated isr flag to enable Incremental Static Regeneration.

For backward compatibility, we keep converting swr and static route rules to isr for these two presets. If you were previously depending on swr and static route rules, we highly recommend to upgrade nitro and switch to isr flag:

routeRules: {
--  '/blog/**': { swr: 3000 },
++  '/blog/**': { isr: 3000 },
}

If you like to leverage Nitro Native SWR cache (stored in storage), you can opt-in using future.nativeSWR: true (nuxt: nitro.future.nativeSWR) config.

Vercel KV Storage

In collaboration with the Vercel team, Nitro now supports seamless integration with Vercel KV Store. See docs for usage information.

Cloudflare Module Worker Preset

You can opt-in to the new Cloudflare Module Worker output format.

The cloudflare pages preset is also upgraded to the worker format with this release

First-class static targets

While Nitro is a server builder, it can be also used to prerender all routes using a renderer and output only static output. New static ,vercel-static, netlify-static and github-pages presets are now available to only output prerender and skip the production server build.

Config HMR support

You can now directly edit route rules and runtime config within nitro.config without the need to restart the nitro server! See #1175 for more information.

Dynamic App Config and Runtime Config

Previously, both useAppConfig() and useRuntimeConfig() were returning a frozen object. Now using useAppConfig(event) and useRuntimeConfig(event) you can have a fully dynamic interface, enabling dynamic, per-request config and support for environments such as Cloudflare where env is only available during the request lifecycle.

If you were previously using useAppConfig() and useRuntimeConfig() in an ambient context (outside of event handlers and composable functions, we highly recommend to migrate to the new API:

-- const appConfig = useAppConfig()

export default eventHandler(event => {
++ const appConfig = useAppConfig(event) 
})

See #1154 for more information.

Experimental Swagger and Open API support

Swagger and OpenAPI are de facto standard tools for documenting server API routes. You can now see all auto-generated API docs by enabling experimental.openAPI: true (nuxt: nitro.experimental.openAPI: true) and opening /_nitro/swagger UI.

See #1162 for more information.

We are working to bring route-level meta definition for an even better and more detailed docs generator.

New Documentation and Branding

Nitro docs and logo are live with a new fancier design at nitro.unjs.io


🚀 Enhancements

  • Add Cloudflare module worker support (#681)
  • vercel, netlify: Introduce isr route rule (#1124)
  • Add static preset (#1127)
  • Add vercel-static and netlify-static presets (#1073)
  • Add github-pages preset (#1133)
  • Pass resolved config to rollup:before hook (#1160)
  • Config reload support for nitro dev (#1173)
  • Config hmr support for routeRules and rutimeConfig (#1175)
  • Support dynamic app config and runtime config (#1154)
  • Experimental /_nitro/openapi.json and /_nitro/swagger for dev mode (#1162)
  • vercel: Add support for specifying edge regions (#1192)
  • future.nativeSWR (#1212)

🔥 Performance

  • Export defineNitroConfig from nitro/config (#1174)

🩹 Fixes

  • Separate typesDir from tsConfigDir (#1146)
  • cloudflare: Expose env from module context (#1147)
  • proxy: Append request query params for single proxy route rules (#1163)
  • vercel, netlify: Keep default behavior for static and swr to isr mapping (#1155)
  • Apply chunkFileNames on windows (#1189)
  • pkg: Allow installing on node v20 and above (#1204)

💅 Refactors

  • cli: Migrate to unjs/citty (#1157)
  • Move swagger and openapi behind experimental flag (2079cab)

📖 Documentation

  • Fix typo (#1131)
  • Update serverAssets example (#1156)
  • Add edge releases channel (2793f51)
  • get-started: H2 instead of h3 (ff3964e)
  • routing: Add route rules (46740e6)
  • routing: Add missing import (30675d4)
  • Fix syntax issue in guide > storage (#1180)
  • Update (1e5bb86)
  • Fix typo (#1185)
  • Fix typo (#1190)
  • vercel: Add vercel kv storage section (#1210)
  • Update branding (#1188)
  • Update vercel-storage (ffff9db)

✅ Tests

  • Enable vercel-edge test (7951532)

❤️ Contributors

Don't miss a new nitro release

NewReleases is sending notifications on new releases.