Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Automatically generates /llms.txt markdown documentation for your Nuxt application.

License

NotificationsYou must be signed in to change notification settings

nuxtlabs/nuxt-llms

Repository files navigation

nuxt-llms-social-card

Nuxt LLMs

npm versionnpm downloadsLicenseNuxt

Nuxt LLMs automatically generatesllms.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.

Features

  • Generates & prerenders/llms.txt automatically
  • Generate & prerenders/llms_full.txt when enabled
  • Customizable sections directly from yournuxt.config.ts
  • Integrates with Nuxt modules and your application via the runtime hooks system

Quick Setup

  1. Install the module:
npm i nuxt-llms
  1. Registernuxt-llms in yournuxt.config.ts:
exportdefaultdefineNuxtConfig({modules:['nuxt-llms']})
  1. Configure your application details:
exportdefaultdefineNuxtConfig({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 ✨

Options

  • domain(required): The domain of the application
  • title: The title of the application, will be displayed at the top of the documentation
  • description: The description of the application, will be displayed at the top of the documentation right after the title
  • sections: 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 section
    • description: The description of the section
    • links: The links of the section
      • title(required): The title of the link
      • description: The description of the link
      • href(required): The href of the link
  • notes: 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: Thellms_full.txt configuration. Setting this option will enable thellms_full.txt route.
    • title: The title of the llms_full documentation
    • description: The description of the llms_full documentation

Documentation Formats

The module generates two different documentation formats:

llms.txt

The/llms.txt route generates a concise, structured documentation that follows thellms.txt specification. This format is optimized for both human readability and AI consumption. It includes:

  • Application title and description
  • Organized sections with titles and descriptions
  • Links with titles, descriptions, and URLs
  • Optional notes section

llms_full.txt

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 thellms_full.txt route, you need to enable it by settingfull.title andfull.description in yournuxt.config.ts.

exportdefaultdefineNuxtConfig({llms:{domain:'https://example.com',title:'My Application',full:{title:'Full Documentation',description:'Full documentation of the application',},},})

Extending the documentation using hooks

The module provides a hooks system that allows you to dynamically extend both documentation formats. There are two main hooks:

Available 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 event
  • options: 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 event
  • options: ModuleOptions - The module options that you can modify to add sections, links, etc.
  • contents: string[] - Array of content sections you can add to or modify

Using Hooks in Your Application

Create a server plugin in yourserver/plugins directory:

// server/plugins/llms.tsexportdefaultdefineNitroPlugin((nitroApp)=>{// Method 1: Using the hooks directlynitroApp.hooks.hook('llms:generate',(event,options)=>{// Add a new section to llms.txtoptions.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 functionnitroApp.hooks.hook('llms:generate:full',(event,options,contents)=>{// Add detailed documentation to llms_full.txtcontents.push(`## API Authentication### Bearer TokenTo authenticate API requests, include a Bearer token in the Authorization header:\`\`\`Authorization: Bearer <your-token>\`\`\`### API KeysFor server-to-server communication, use API keys:\`\`\`X-API-Key: <your-api-key>\`\`\`    `)})})

Using Hooks in Nuxt Modules

If you're developing a Nuxt module that needs to extend the LLMs documentation:

  1. Create a server plugin in your module:
// module/runtime/server/plugins/my-module-llms.tsexportdefaultdefineNitroPlugin((nitroApp)=>{nitroApp.hooks.hook('llms:generate',(event,options)=>{options.sections.push({title:'My Module',description:'Documentation for my module features',links:[/* ... */]})})})
  1. Register the plugin in your module setup:
import{defineNuxtModule,addServerPlugin}from'@nuxt/kit'import{fileURLToPath}from'url'exportdefaultdefineNuxtModule({setup(options,nuxt){construntimeDir=fileURLToPath(newURL('./runtime',import.meta.url))addServerPlugin(resolve(runtimeDir,'server/plugins/my-module-llms'))}})

Integrations

Nuxt Content

Nuxt Content ^3.2.0 comes with built-in support for LLMs documentation. You can usenuxt-llms with@nuxt/content to efficiently write content and documentation for your website and generate LLM-friendly documentation without extra effort. Content module usesnuxt-llms hooks and automatically adds all your contents intollms.txt andllms_full.txt documentation.

All you need is to install both modules and write your content files in thecontent directory.

exportdefaultdefineNuxtConfig({modules:['nuxt-llms','@nuxt/content'],llms:{domain:'https://example.com',title:'My Application',description:'My Application Description',},})

Checkout theNuxt Content documentation for more information on how to write your content files.

And checkout theNuxt Content llms documentation for more information on how to customize LLMs contents withnuxt-llms and@nuxt/content.

💻 Development

  • Clone repository
  • Install dependencies usingpnpm install
  • Prepare usingpnpm dev:prepare
  • Build usingpnpm prepack
  • Try playground usingpnpm dev
  • Test usingpnpm test

License

MIT License

Copyright (c) NuxtLabs

About

Automatically generates /llms.txt markdown documentation for your Nuxt application.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp