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

feat(kit): useNitro() utility #7557

Merged
merged 8 commits into from Sep 15, 2022
Merged

feat(kit): useNitro() utility #7557

merged 8 commits into from Sep 15, 2022

Conversation

pi0
Copy link
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

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

@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.

None yet

2 participants