feat: add Nitro v3 Vite plugin integration with nitro: hook#50
Merged
productdevbook merged 2 commits intomainfrom Nov 4, 2025
Merged
feat: add Nitro v3 Vite plugin integration with nitro: hook#50productdevbook merged 2 commits intomainfrom
productdevbook merged 2 commits intomainfrom
Conversation
This implements the new Nitro v3 pattern where Vite plugins can include
a `nitro:` key to automatically register Nitro modules, eliminating the
need for separate configuration.
**Changes:**
- Extract shared setup logic into `src/setup.ts` for reuse
- Update `src/vite.ts` to include `nitro: { setup() }` hook
- Accept `NitroGraphQLOptions` in the Vite plugin function
- Update `src/index.ts` to use the extracted setup function
- Update Vite playground to demonstrate the new single-import pattern
**Benefits:**
- Single import: users only need `graphql()` from `nitro-graphql/vite`
- Plugin order independence (as per Nitro v3 changes)
- Better DX and consistency with modern Nitro v3 patterns
- Full backward compatibility with existing `modules: ['nitro-graphql']` approach
**Usage:**
```typescript
// New pattern (recommended)
import { graphql } from 'nitro-graphql/vite'
import { nitro } from 'nitro/vite'
export default defineConfig({
plugins: [
graphql({ framework: 'graphql-yoga' }),
nitro()
]
})
```
**Related:**
- Nitro PR: nitrojs/nitro#3712
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Deploying nitro-graphql with
|
| Latest commit: |
705cb3c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3cda0bf9.nitro-graphql.pages.dev |
| Branch Preview URL: | https://feat-vite-plugin-nitro-integ.nitro-graphql.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the new Nitro v3 pattern where Vite plugins can include a
nitro:key to automatically register Nitro modules. This allows users to configure nitro-graphql with a single import instead of separately configuring both the Vite plugin and Nitro module.Changes
src/setup.tsfor reuse between the Nitro module and Vite pluginsrc/vite.tsto includenitro: { setup() }hook that auto-registers the moduleNitroGraphQLOptionsin the Vite plugin function for configurationsrc/index.tsto use the extracted setup functionBenefits
graphql()fromnitro-graphql/vitemodules: ['nitro-graphql']approach still worksUsage
New pattern (recommended)
Old pattern (still supported)
Test plan
Related
🤖 Generated with Claude Code