Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

feat(kit): useNitro() utility#7557

Merged
pi0 merged 8 commits intomainfrom
feat/kit-use-nitro
Sep 15, 2022
Merged

feat(kit): useNitro() utility#7557
pi0 merged 8 commits intomainfrom
feat/kit-use-nitro

Conversation

@pi0
Copy link
Copy Markdown
Member

@pi0 pi0 commented Sep 15, 2022

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Taling with @danielroe, it is sometimes required to access nitro instance mainly to access resolved configuration. But it is tricky because nitro is intentionally initialized after all modules to reflect configuration changes by them.

This PR exposes useNitro() to be used within or after ready hook:

Note: Users should not modify the nitro configuration using this instance either. Because we have more than once instance (one is used for prerendering) and also nitro does not reflects configuration changes always after initializing. It is a read-only instance.

import { useNitro } from '@nuxt/kit'
nuxt.hook('ready', () => {
  console.log(useNitro())
})

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0 pi0 requested a review from danielroe September 15, 2022 12:43
@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 15, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit ff5fbc3
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6323215b8f6e9d000998871d

Comment thread packages/kit/src/nitro.ts
Comment thread packages/schema/src/types/nuxt.ts Outdated
@pi0 pi0 merged commit b933015 into main Sep 15, 2022
@pi0 pi0 deleted the feat/kit-use-nitro branch September 15, 2022 16:10
@pi0 pi0 mentioned this pull request Sep 15, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants