Nuxt LLMs automatically generates llms.txt markdown documentation for your Nuxt application. It provides runtime hooks to collect data from various sources (CMS, Nuxt Content, etc.) and generate structured documentation in a text-based format.
/llms.txt automatically/llms-full.txt when enablednuxt.config.tsnpm i nuxt-llms
nuxt-llms in your nuxt.config.ts:export default defineNuxtConfig({
modules: ['nuxt-llms']
})
export default defineNuxtConfig({
modules: ['nuxt-llms'],
llms: {
domain: 'https://example.com',
title: 'My Application',
description: 'My Application Description',
sections: [
{
title: 'Section 1',
description: 'Section 1 Description',
links: [
{
title: 'Link 1',
description: 'Link 1 Description',
href: '/link-1',
},
{
title: 'Link 2',
description: 'Link 2 Description',
href: '/link-2',
},
],
},
],
},
})
That's it! You can visit /llms.txt to see the generated documentation ✨
domain(required): The domain of the applicationtitle: The title of the application, will be displayed at the top of the documentationdescription: The description of the application, will be displayed at the top of the documentation right after the titlesections: The sections of the documentation.
Section are consisted of a title, one or more paragraphs of description and possibly a list of links.
Each section is an object with the following properties:
title(required): The title of the sectiondescription: The description of the sectionlinks: The links of the section
title(required): The title of the linkdescription: The description of the linkhref(required): The href of the linknotes: The notes of the documentation. Notes are a special section which always appears at the end of the documentation. Notes are useful to add any information about the application or documentation itself.full: The llms-full.txt configuration. Setting this option will enable the llms-full.txt route.
title: The title of the llms-full documentationdescription: The description of the llms-full documentationThe module generates two different documentation formats:
The /llms.txt route generates a concise, structured documentation that follows the llms.txt specification. This format is optimized for both human readability and AI consumption. It includes:
The /llms-full.txt route provides a more detailed, free-form documentation format. This is useful to reduce crawler traffic on your application and provide a more detailed documentation to your users and LLMs.
By default module does not generate the llms-full.txt route, you need to enable it by setting full.title and full.description in your nuxt.config.ts.
export default defineNuxtConfig({
llms: {
domain: 'https://example.com',
title: 'My Application',
full: {
title: 'Full Documentation',
description: 'Full documentation of the application',
},
},
})
The module provides a hooks system that allows you to dynamically extend both documentation formats. There are two main hooks:
llms:generate(event, options)This hook is called for every request to /llms.txt. Use this hook to modify the structured documentation, It allows you to add sections, links, and metadata.
Parameters:
event: H3Event - The current request eventoptions: ModuleOptions - The module options that you can modify to add sections, links, etc.llms:generate:llms-full(event, options, contents)This hook is called for every request to /llms-full.txt. It allows you to add custom content sections in any format.
Parameters:
event: H3Event - The current request eventoptions: ModuleOptions - The module options that you can modify to add sections, links, etc.contents: string - Array of content sections you can add to or modifyCreate a server plugin in your server/plugins directory:
// server/plugins/llms.ts
export default defineNitroPlugin((nitroApp) => {
// Method 1: Using the hooks directly
nitroApp.hooks.hook('llms:generate', (event, options) => {
// Add a new section to llms.txt
options.sections.push({
title: 'API Documentation',
description: 'REST API endpoints and usage',
links: [
{
title: 'Authentication',
description: 'API authentication methods',
href: `${options.domain}/api/auth`
}
]
})
})
// Method 2: Using the helper function
nitroApp.hooks.hook('llms:generate:full', (event, options, contents) => {
// Add detailed documentation to llms-full.txt
contents.push(`## API Authentication
### Bearer Token
To authenticate API requests, include a Bearer token in the Authorization header:
\`\`\`
Authorization: Bearer <your-token>
\`\`\`
### API Keys
For server-to-server communication, use API keys:
\`\`\`
X-API-Key: <your-api-key>
\`\`\`
`)
})
})
If you're developing a Nuxt module that needs to extend the LLMs documentation:
// module/runtime/server/plugins/my-module-llms.ts
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('llms:generate', (event, options) => {
options.sections.push({
title: 'My Module',
description: 'Documentation for my module features',
links: [/* ... */]
})
})
})
import { defineNuxtModule, addServerPlugin } from '@nuxt/kit'
import { fileURLToPath } from 'url'
export default defineNuxtModule({
setup(options, nuxt) {
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
addServerPlugin(resolve(runtimeDir, 'server/plugins/my-module-llms'))
}
})
Nuxt Content ^3.2.0 comes with built-in support for LLMs documentation. You can use nuxt-llms with @nuxt/content to efficiently write content and documentation for your website and generate LLM-friendly documentation without extra effort. Content module uses nuxt-llms hooks and automatically adds all your contents into llms.txt and llms-full.txt documentation.
All you need is to install both modules and write your content files in the content directory.
export default defineNuxtConfig({
modules: ['nuxt-llms', '@nuxt/content'],
llms: {
domain: 'https://example.com',
title: 'My Application',
description: 'My Application Description',
},
})
Checkout the Nuxt Content documentation for more information on how to write your content files.
And checkout the Nuxt Content llms documentation for more information on how to customize LLMs contents with nuxt-llms and @nuxt/content.
pnpm installpnpm dev:preparepnpm prepackpnpm devpnpm testCopyright (c) NuxtLabs