Index of every page on this site: llms.txt

Nitro Hooks

site-config:init

Type:

export interface HookSiteConfigInitContext {
  event: Pick<RequestEvent, 'context'>
  siteConfig: SiteConfigStack
}

Modify site config after initialization.

The event type includes only context. Pass event to getNitroOrigin(event) to read the request origin.

server/plugins/site-config.ts
import { getNitroOrigin } from '#site-config/server'

export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('site-config:init', ({ event, siteConfig }) => {
    const origin = getNitroOrigin(event)
    if (origin.startsWith('https://fr.')) {
      siteConfig.push({
        _context: 'french nitro plugin', // helps you debug
        name: 'Mon Site',
        url: 'https://fr.example.com',
      })
    }
  })
})
Was this page helpful?