Nuxt API

Nuxt Hooks

Last updated by Harlan Wilton in fix!: rework module.

'ai-ready:page:markdown'

Type: (ctx: ParsedMarkdownResult & { route: string }) => void | Promise<void>

Called per page during prerender. Modify markdown content before it's written to llms-full.txt and page-data.jsonl.

nuxt.config.ts
export default defineNuxtConfig({
  hooks: {
    'ai-ready:page:markdown': (ctx) => {
      // Add frontmatter
      ctx.markdown = `---\ntitle: ${ctx.title}\n---\n\n${ctx.markdown}`
    }
  }
})

Context:

PropertyTypeDescription
routestringPage route (e.g., /about)
markdownstringGenerated markdown (modify this)
titlestringPage title
descriptionstringPage description
headingsArray<Record<string, string>>Extracted headings from page
updatedAtstring?Last modified date (from sitemap)

Only fires during nuxi generate or nuxi build --prerender.

'ai-ready:llms-txt'

Type: (payload: { sections: LlmsTxtSection[], notes: string[] }) => void | Promise<void>

Called before llms.txt generation. Add or modify sections and notes.

nuxt.config.ts
export default defineNuxtConfig({
  hooks: {
    'ai-ready:llms-txt': (payload) => {
      payload.sections.push({
        title: 'Custom APIs',
        description: 'Additional endpoints',
        links: [
          { title: 'Search', href: '/api/search', description: 'Search endpoint' }
        ]
      })
      payload.notes.push('Built with Nuxt AI Ready')
    }
  }
})

Payload:

PropertyTypeDescription
sectionsLlmsTxtSection[]Sections with title, description, links
notesstring[]Notes at end of file

Mutable pattern — modify arrays directly, don't return values.

Did this page help you?