Skip to content

feat(config): add defaultPreset to customize the fallback preset - #4299

Merged
pi0 merged 1 commit into
mainfrom
feat/default-preset
Jun 1, 2026
Merged

pi0 merged 1 commit into
mainfrom
feat/default-preset

Conversation

@pi0x

@pi0x pi0x commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Adds a new defaultPreset: string | <Preset> config option that customizes the preset used as the fallback when preset is not set and none of the known hosting providers are auto-detected. By default Nitro falls back to the runtime-based preset (node, or deno/bun on those runtimes); defaultPreset lets you override that default (e.g. to node-cluster) while keeping the normal precedence intact — an explicit preset, the NITRO_PRESET env var, and auto-detected providers (Vercel, Netlify, Cloudflare Pages, …) all still take priority. It accepts either a preset name or an inline preset definition (the latter is injected as a base layer so user config still overrides it, and its nested extends/preset are resolved recursively). Includes unit tests for the resolver fallback paths and docs.

🤖 Generated with Claude Code

Customize the preset used as the auto-detect fallback (instead of
`node`) when no preset is set and no hosting provider is detected.
Accepts a preset name or an inline preset definition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment Jun 1, 2026 5:29pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c09c2d7-23c8-4bac-8d1e-c39203902825

📥 Commits

Reviewing files that changed from the base of the PR and between 498c9d8 and 05d0360.

📒 Files selected for processing (5)
  • docs/3.config/0.index.md
  • src/config/loader.ts
  • src/presets/_resolve.ts
  • src/types/config.ts
  • test/unit/default-preset.test.ts

📝 Walkthrough

Walkthrough

This pull request introduces a defaultPreset configuration option that Nitro uses as a fallback when no explicit preset is set and no hosting provider is auto-detected. The implementation spans type definitions, preset resolution logic, config loader integration, comprehensive tests, and user documentation.

Changes

Nitro defaultPreset Configuration Option

Layer / File(s) Summary
Config type definitions
src/types/config.ts, src/presets/_resolve.ts
New optional defaultPreset?: PresetNameInput | NitroPreset field added to NitroConfig. resolvePreset function signature extended with opts.defaultPreset parameter.
Preset resolution fallback
src/presets/_resolve.ts
resolvePreset implements fallback handling: string defaultPreset values are recursively resolved; inline preset objects are normalized with _meta.name set to "default" while preserving existing metadata.
Config loader integration
src/config/loader.ts
Production preset auto-detection reads defaultPreset, passes it to resolvePreset, stores inline preset configurations, and intercepts preset resolution to return cloned configs for inline defaults.
Unit tests
test/unit/default-preset.test.ts
Mocked Vitest suite testing fallback to node-server, string and inline object defaultPreset resolution, metadata normalization, and explicit preset precedence over defaultPreset.
User documentation
docs/3.config/0.index.md
Documents defaultPreset option as fallback behavior, specifies precedence rules with explicit preset and provider auto-detection, includes defineConfig example.

🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/default-preset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4299

commit: 05d0360

@pi0
pi0 marked this pull request as ready for review June 1, 2026 17:32
@pi0
pi0 self-requested a review as a code owner June 1, 2026 17:32
@pi0
pi0 merged commit a259736 into main Jun 1, 2026
12 of 13 checks passed
@pi0
pi0 deleted the feat/default-preset branch June 1, 2026 17:33

This branch was successfully deployed

1 active deployment
Preview — 05d0360d Deployed Jun 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants