Skip to content

Releases: nitrojs/nitro

v2.10.0

01 Nov 23:09
@pi0 pi0
Compare
Choose a tag to compare

💬 Release Dicussion

🏠 New home

After almost 4 years of Nitro development, it's time to evolve Nitro into a larger community and ecosystem.

  • Current nitro-related repositories have been moved under the nitrojs Github org.
  • Nitro documentation is hosted under a new shorter domain name: nitro.build.
  • nitropack npm package is in transition to become nitro.

We have created a new community. You can follow Nitro updates on X via @nitrojsdev and on Bluesky via @nitro.build and feel free to join our new Discord server if you like to be involved ❤️.

🛠️ Major internal overhaul

We have made several (non-breaking) refactors in the Nitro codebase to improve long-term maintenance and structure consistency with the upcoming Nitro v3 releases.

Nitro 2.10 is a cumulative update with over 245 commits, 400+ changed files, 22,018 additions, and 13,207 deletions from 65 contributors, preparing for the next steps toward the Nitro 3 release. (see all changes)

src/* structure is more modular (#2473), all logic related to presets moved to src/presets/* (#2446) and internal type checks are more stricter (#2370, #2529).

Important

If you previously imported any utility from #internal/nitro/* or nitropack/runtime/* you should change them to #imports to avoid issues.

📅 Compatibility date

Deployment providers introduce new features that Nitro presets can leverage, but some of them need to be explicitly opted into.

Nitro introduces a new compatibilityDate configuration (#2511) that allows leveraging the latest platform enhancements. The Cloudflare and Netlify presets now use this feature. If this configuration is not provided, Nitro will continue using the current (v2.9) behavior for presets.

Migration:

export default defineNitroConfig({
+++  compatibilityDate: "2024-11-01",
});

🗂️ Environment-specific handlers

Each route handler in server/routes/* and server/api/* is always included in the server bundle for development, prerender, and production.

With the new environment-specific event handlers (#2272), you can now specify handlers that are included only under certain conditions:

  • .dev (e.g., server/api/inspect.dev.ts): Included only in development mode.
  • .prerender (e.g., server/api/og_image.prerender.ts): Included only in the prerendering stage.
  • .prod (e.g., server/api/health.prod.ts): Included only in the production bundle.

This feature allows for conventionally having multiple versions of handlers (e.g., routes/admin.dev.ts + routes/admin.prod.ts).

Additionally, if you add route handlers programmatically (via the handlers: [] Nitro config), you can use the env key to specify preset-specific filters.

📍 Route groups

You can use (...)/ directory names inside server/api/* and server/routes/* to logically group handlers without dir being part of the path (#2664).

For example, having server/api/(group)/test.ts, will add a /api/test route.

📜 production mode OpenAPI support

The experimental OpenAPI feature can now be enabled in production mode (#2570).

To enable it, set openAPI.production in the Nitro configuration.

export default defineNitroConfig({
  experimental: {
    openAPI: true,
  },
  openAPI: {
    // IMPORTANT: make sure to protect OpenAPI routes if necessary!
    production: "runtime", // or 'prerender'
  },
});

New OpenAPI routes:

  • /_openapi.json: OpenAPI v2 JSON to be used in external tools
  • /_swagger: built-in Swagger UI
  • /_scalar: built-in Scalar UI

📦 Upgraded dependencies

🎛️ Preset updates

Cloudflare

cloudflare-module preset, with compatibilityDate config set to 2024-09-19 or later, leverages new Static Assets support to allow serving static assets directly from cloudflare CDN with low latency and without hitting the worker and occurring costs (#2800) (Note: Please beware of current limitations while this feature is in Beta).

A new (experimental) cloudflare-durable preset is available which extends coudflare-module to allow leveraging Cloudflare Durable objects(#2801). This allows using WebSockets with pub/sub support for use cases like chat rooms or live collaboration (check out nuxt-tiptap for a demo).

Nitro 2.10 added several hooks such as cloudflare:email and cloudflare:queue (#2487) and cloudflare:scheduled, cloudflare:email, cloudflare:queue, cloudflare:tail and cloudflare:trace for cloudflare-module preset (#2795) usable with plugins.

With the cloudflare-pages preset, if cloudflare: { wrangler: { ... } } is set in nitro config, Nitro will automatically merge it with wrangler.toml in your project root during build.

Netlify

netlify preset uses Netlify Functions 2.0 format when compatibilityDate is set to 2024-05-07 or later (#2406). This allows streaming responses (demo), better support for hybrid rendering (prerender: true route rule works as intended), improves background request generation, fixing bugs with set-cookie: undefined on responses and Netlify Blobs will now work out of the box.

Previously, ISR in Nitro had been implemented on Netlify via proprietary On-Demand Builders platform primitive, which only supported "v1" Functions. Now that there's momentum around Targeted HTTP Cache Control and that Netlify supports it, we can implement ISR in Nitro via these simple, standard HTTP headers instead. With the isr route rule, the new preset uses a new durable cache-control directive (#2571).

All netlify presets now leverage from better static asset handling to avoid extra function invocations and saving costs (#2822, #2823).

Vercel

When using isr route rule, by default, query paramas are ignored by cache. Now, you can pass an options object to isr: {} route rule to configure caching behavior (#2780). Read more in docs.

AWS Lambda

We have experimented streaming support for aws-lambda (#2412) and added it as an opt-in flag to enable streaming in supported deployments using awsLambda: { streaming: true } nitro config (#2786).

New presets

We have added support for genezio (#2637) and zerops (#2698) deployment providers.

Other changes

🚀 Enhancements

  • Generate types for runtime config (#2306)
  • Support ignore option for server assets (#2302)
  • Expose getRouteRulesForPath from nitro runtime (#2238)
  • openapi: Support configuration via openapi (#2299)
  • Environment specific event handlers (#2272)
  • Experimental defineRouteMeta (#2102)
  • Allow customizing apiBaseURL, apiDir and routesDir (#1763)
  • Add gitlab-pages static provider (#2420)
  • Compatibility date support (#2511)
  • config: Warn if the runtime config is not serializable (#2542)
  • open-api: Production mode support (#2570)
  • deno-server: Use output node_modules for start task ([#2687](https://github.com/...
Read more

v2.9.7

27 Jun 16:21
@pi0 pi0
Compare
Choose a tag to compare

Note

Release of Nitro 2.10 might little bit take longer (after Nitro 3.0 release) in order to make sure all major refactors are nonbreaking and tested enough. In the meantime, 2.9.7 adds important fixes.

Full changelog: v2.9.6...v2.9.7

🩹 Fixes

  • github-pages: Prerender / by default (#2334) (8b5cbc5)
  • Deduplicate plugins (#2391) (4293b8b)
  • Add .tsx and .jsx to node-resolve extensions (#2398) (d2c0d74)
  • typescript: Set compilerOptions.noEmit to avoid tsconfig.json warning (#2402) (6b6777e)
  • prerender: Only try to add / after prerender:routes hook (#2348) (fb88efd)
  • Pass custom entry filename when resolving prerenderer (#2461) (9bd6622)
  • public-assets: Do not shadow paths that share prefix (#2516) (72db848)
  • openapi: Update swagger-ui version to v5 for OpenAPI v3.1 support (#2343) (9e2cd8a)
  • Convert CapturedErrorContext to interface to allow type augmentation (#2393) (45ff175)
  • renderer: Check full path for /favicon.ico placeholder (#2553) (b86bb45)
  • Use relative paths in nitro-config.d.ts (#2471) (4d70b75)
  • prerender: Extract links from explicit html routes (#2517) (e1f87c5)
  • cloudflare-pages: Remove .html extension from generated _routes.json (#2498) (79b85fe)
  • core: Resolve modules with esm compatibility (#2514) (4657ada)
  • Update cli preset with esm module format (#2539) (f6f2327)
  • types: Infer types correctly when method is omitted (#2551) (f76d21b)
  • deno-server: Explicitly remove cert/key from options if either is not set (#2373) (d887f4a)
  • azure: Correctly handle maxAge cookie option (#2403) (aabdc9c)
  • netlify: Ensure preview command is correct (#2561) (d16a47b)
  • iis: Deep merge configs (#2358) (f03addd)
  • iis: Parse without explicitArray to allow merging web.config (#2457) (6c3e080)
  • vercel: Support custom baseURL (#2464) (61f2079)
  • Lower-case accepted handler method (#2382) (e60e114)
  • defineCachedEventHandler: Add event.context.cache (#2519) (fc3968b)

❤️ Contributors

v2.9.6

02 Apr 22:51
@pi0 pi0
3cb566e
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • Generate root/src directory aliases (#2318)
  • externals: Skip resolving virtual ids start with \0 (#2321)
  • types: Account for undefined value for $fetch return type (#2327)
  • cloudflare-pages: Use predefined wildcards in routes.exclude (#2319)

📖 Documentation

  • Remove outdated nightly warning (#2317)

❤️ Contributors

v2.9.5

25 Mar 19:29
@pi0 pi0
Compare
Choose a tag to compare

compare changes

✅ Fixes and Improvements

  • openapi: Add experimental /_nitro/scalar endpoint (#2252)
  • openapi: Use dynamic host + port (#2216)
  • openapi: Add schema to generated parameters (#2235)
  • openapi: Avoid double slash for base (fdf7e70a)
  • options: Set scheduledTasks to an empty object by default (#2285)
  • prerender: Call nitroApp close hook when done prerendering (#2287)
  • types: Return T from Serialize when it extends undefined (#2286)
  • raw: Exclude yaml from raw plugin (#2275)
  • externals: Check explicit inline rules on resolved id (#2288)
  • raw: Allow importing relative paths (#2289)
  • types: Make c12 env types available for NitroConfig (#2292)
  • netlify-edge: Write _headers and _redirects (#2291)
  • cloudflare-pages: Write _headers and _redirects for non static builds (#2290)
  • netlify: Allow writing config.json (#2264)
  • Allow importing utils from nitropack/runtime (#2314)
  • openapi: Upgrade to openapi 3.1 (#2297)
  • Use .d.ts for runtime generated types (#2313)

📖 Documentation

  • routing: Add note about middleware execution order (#2282)
  • routing: Fx link to h3 object syntax handler (#2281)
  • Update tasks return value (8a62e7db)
  • cache: Add a note for serverless environment (dc83a2e2)
  • Fix typo (#2298)

❤️ Contributors

v2.9.4

15 Mar 16:48
@pi0 pi0
cc24c20
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • Handle path negations when scanning public assets (#2250)
  • pkg: Add ioredis as unstorage peer dependency (#2266)

📖 Documentation

  • Fix server assets example path (#2248)
  • Remove duplicate integrity key (#2246)
  • Fix wording (#2261)
  • Remove nightly notice (39bc3f2e)
  • tasks: Update dev server usage (#2240)
  • cache: Add example usage for cache.varies (#2241)

❤️ Contributors

v2.9.3

10 Mar 10:15
@pi0 pi0
52b65c7
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • raw: Use mime to chck binary types and exclude .json (#2239)

📖 Documentation

❤️ Contributors

v2.9.2

08 Mar 21:01
@pi0 pi0
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • database: CamelCase the connector name (#2228)
  • Respect imports.autoImport: false (#2226)
  • server-assets: Mark yaml, json, json5 and csv as text (#2229)
  • import-meta: Import process from node:process for node compatible builds (deno) (#2225)

📖 Documentation

  • deploy: Add link to zero config providers (#2206)
  • fetch: Fix typo (#2209)
  • Fix typo (#2211)
  • Fix typo (#2205)
  • Remove lagon (#2204)
  • Update url for experimental database feature (#2210)
  • providers: Improve formatting & use new undocs components (#2202)
  • Improve cache page (674089b3)

❤️ Contributors

v2.9.1

29 Feb 11:33
@pi0 pi0
ed8a3db
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • Dev:remoteAddress might be undefined for x-forwarded-for (#2198)
  • Disable scheduled tasks in testing environment (#2200)

📖 Documentation

  • Add websocket chat demo to websocket api page (#2189)
  • Fix typo (#2190)
  • Fix typo (#2194)

🤖 CI

  • Skip cloudflare-pages test for windows (#2199)

❤️ Contributors

v2.9.0

28 Feb 12:34
@pi0 pi0
Compare
Choose a tag to compare

🎉 Released live from Vue.js Amsterdam

⭐ What is new?

📖 New Documentation

🧦 WebSockets API

🗄️ Database Layer

🏃‍♂️ Nitro Tasks

☑️ ESM-Ready WASM

All changes

compare changes

🚀 Enhancements

  • prerender: Support function/RegExp for prerender.ignore (#1966)
  • CLI: Show meta framework name on server build success (#1955)
  • Presets: Add zeabur preset (#1942)
  • Experimental nitro tasks (#1929)
  • Add types:extend hook (#1715)
  • Allow oveeridng nested runtime config with env (#1831)
  • wasm: Universal support with esm import syntax (#2017)
  • wasm: Migrate to unjs/unwasm (#2037)
  • zeabur: Support zeaburStatic and auto detect preset (#2014)
  • runtime-config: Experimental env expansion support (#2043)
  • Support binary server assets (#2107)
  • Experimental websocket support (#2170)
  • dev: Expose upgrade handler (5374429f)
  • Experimental database layer (#1351)
  • Experimental scheduled tasks (#2179)
  • cache: Support async shouldBypassCache and shouldInvalidateCache (#2181)
  • prerender: Add total prerender time (#2130)
  • Presets: Add koyeb preset (#1248)
  • providers: Support alwaysdata hosting provider (#1790)
  • routeRules: Allow wildcard redirects (#1976)

🩹 Fixes

  • rollup: Avoid preserving relative externals (#1972)
  • wasm: Directly generate chunk exports (#2003)
  • iis-node: Correctly escape backslashes for port fix (#2020)
  • deno-deploy: Shim x-forwarded-for and x-forwarded-proto headers (#2026)
  • Add baseURL to openapi generated url (#2049)
  • dev: Correctly set x-forwarded-* headers (29ddd948)
  • azure: Add 18 and 20 to supported node versions (#2077)
  • azure: Pass body to the context as-is (#2079)
  • dev: Only mock consola in production (#2110)
  • Default to bundler module resolution (#2120)
  • Handle optional routeHandler.route in rollup chunk (#2152)
  • File extension stripping in writeTypes function (#2139)
  • cache: Detect malformed data read from storage (#2161)
  • cacheEventHandler: Provide event.fetch and event.$fetch (#2066)
  • module: Resolve modules with jiti directly (#2030)

💅 Refactors

  • Include framework name in more build packages (#1973)
  • cloudflare: Remove --local from perview commands (#1979)
  • cloudflare: Remove unused import (#1980)
  • rollup: Improve generated chunk names (#2004)
  • Use name exports in presets entry (1abfc3e5)
  • Reimplement WASM plugin (#2031)
  • Various improvements around tasks api (#2175)
  • tasks: Stablize api (#2178)
  • github-pages: Add --dotfiles to deploy command hint (#2158)

📖 Documentation

  • routing: Update request filtering to match the type of getRequestURL (#1977)
  • config: Fix setResponseHeader example params (#2027)
  • netlify: Add note to make sure publish dist is set to dist (#2035)
  • cloudflare: Various updates, cleanups and fixes (#1981)
  • presets: Deprecate lagon (17f922aa)
  • Update the routing page (#2085)
  • Update the cache page (#2087)
  • Close code-group in cache section (#2093)
  • routing: Escape filename paths and prepend routes folder (#2097)
  • storage: Fix unstorage links (#2101)
  • routing: Fix typo for getRouterParam (#2098)
  • Update the storage page (#2086)
  • Add object syntax for event handler (#2091)
  • Update the configuration page (#2083)
  • Update the assets page (#2088)
  • Create a page on built-in fetch (#2089)
  • Add warning about azure functions stability (#2092)
  • cloudflare: Update deployment guide (#2074)
  • Fix icon of fetch page (#2115)
  • Update getting started page (#2082)
  • Fix links to /guide/auto-imports (#2131)
  • Fix typo in defineCachedFunction example (#2133)
  • Clarify difference between dir and baseURL (#2144)
  • Migrate to undocs (#2163)
  • index: Fix utils link (#2172)
  • websocket: Fix typo (#2173)
  • Fix typo (3017e6e2)
  • vercel: Add monorepo info (#2183)
  • Fix typo (#2182)
  • cloudflare: Add local bindings usage (#2135)
  • Fix link to h3 utils (#2184)
  • deploy: Add platform.sh (#1630)

📦 Build

  • Better dist chunk names (#2005)

✅ Tests

  • cloudflare: Migrate to miniflare v3 (#2018)
  • Enable azure tests behind a flag (#2076)
  • Enable binary response test for all presets (#2078)
  • Avoid prerendering icon.png (cb220f7e)

🤖 CI

  • Fix nightly release job condition (#1975)

❤️ Contributors

v2.8.1

29 Nov 17:51
@pi0 pi0
b53e001
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • dev: Conditionally access worker address for build info (#1947)
  • Force use wasm import strategy for windows (e73b849f)
  • netlify-lambda: Handle base64 encoded body (#1940)
  • cloudflare: Wasm support with dynamic chunks (#1957)
  • prerenderer: Write responses with json signature to original path (#1963)

📖 Documentation

  • cache: Make default value swr: true more clear (#1949)

🏡 Chore

✅ Tests

  • Add tests for wasm (#1951)
  • cloudflare-pages: Remover overlapping include rules (789a13d3)

❤️ Contributors