
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@mdream/nuxt
Advanced tools
Nuxt module for converting HTML pages to Markdown using mdream.
.md extension (e.g., /about → /about.md)llms.txt and llms-full.txt artifacts during prerenderingpnpm add @mdream/nuxt
Add the module to your nuxt.config.ts:
export default defineNuxtConfig({
modules: [
'@mdream/nuxt'
],
})
Done! You can now:
.md extension: Access any route as markdown (e.g., /about.md)When statically generating your site with nuxi generate it will create llms.txt and llms-full.txt artifacts.
The module automatically detects LLM bots and serves markdown without requiring the .md extension:
Accept header contains */* or text/markdown (but not text/html)text/html in Accept header or sec-fetch-dest: document)This means LLM bots automatically receive optimized markdown responses, reducing token usage by ~10x compared to HTML.
Configure the module in your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@mdream/nuxt'],
mdream: {
// Enable/disable the module
enabled: true,
// Pass options to mdream
mdreamOptions: {
// mdream conversion options
},
// Cache configuration (production only)
cache: {
maxAge: 3600, // 1 hour
swr: true // Stale-while-revalidate
}
}
})
enabled (boolean): Enable or disable the module. Default: truemdreamOptions (object): Options passed to mdream's htmlToMarkdown functioncache.maxAge (number): Cache duration in seconds. Default: 3600 (1 hour)cache.swr (boolean): Enable stale-while-revalidate. Default: trueThe module respects the robots meta tag. Pages with noindex will return a 404 error when accessed as markdown:
<script setup>
useHead({
meta: [
{ name: 'robots', content: 'noindex' }
]
})
</script>
When using nuxt generate or static hosting, the module automatically:
.md files for all pagesllms.txt with page listingsllms-full.txt with full contentThese files are placed in the public/ directory and served as static assets.
The module provides several hooks for integrating with other modules (e.g., nuxt-ai-index):
'mdream:config'{lang="ts"}Type: (ctx: ConfigContext) => void | Promise<void>{lang="ts"}
interface ConfigContext {
route: string
options: MdreamOptions
event: H3Event
}
Modify the mdream options before HTML→Markdown conversion. This hook is called during runtime middleware processing, allowing you to dynamically adjust conversion behavior based on the request.
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('mdream:config', async (ctx) => {
// Apply readability preset for documentation routes
if (ctx.route.startsWith('/docs')) {
ctx.options.preset = 'readability'
}
// Add custom plugins dynamically
if (!ctx.options.plugins) {
ctx.options.plugins = []
}
// Filter out advertisements and cookie banners
ctx.options.plugins.push({
beforeNodeProcess(event) {
if (event.node.type === 1) { // ELEMENT_NODE
const element = event.node
const classList = element.attributes?.class?.split(' ') || []
if (classList.includes('advertisement') || classList.includes('cookie-banner')) {
return { skip: true }
}
}
}
})
})
})
'mdream:markdown'{lang="ts"}Type: (ctx: MarkdownContext) => void | Promise<void>{lang="ts"}
interface MarkdownContext {
html: string
markdown: string
route: string
title: string
description: string
isPrerender: boolean
event: H3Event
}
Modify the generated markdown content after conversion. Use this hook for post-processing markdown, tracking conversions, or adding custom response headers.
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('mdream:markdown', async (ctx) => {
// Add footer to all markdown output
ctx.markdown += '\n\n---\n*Generated with mdream*'
// Track conversion for analytics
console.log(`Converted ${ctx.route} (${ctx.title})`)
// Add custom headers
setHeader(ctx.event, 'X-Markdown-Title', ctx.title)
})
})
'mdream:llms-txt:generate'{lang="ts"}Type: (payload: MdreamLlmsTxtGeneratePayload) => void | Promise<void>{lang="ts"}
interface MdreamLlmsTxtGeneratePayload {
content: string
fullContent: string
pages: ProcessedFile[]
}
interface ProcessedFile {
filePath?: string
title: string
content: string
url: string
metadata?: {
title?: string
description?: string
keywords?: string
author?: string
}
}
Modify the llms.txt content before it's written to disk. This hook is called once during prerendering after all routes have been processed. Uses a mutable pattern - modify the payload properties directly.
export default defineNuxtConfig({
modules: ['@mdream/nuxt'],
hooks: {
'mdream:llms-txt:generate': async (payload) => {
// Access all processed pages
console.log(`Processing ${payload.pages.length} pages`)
// Add custom sections to llms.txt
payload.content += `
## API Search
Search available at /api/search with semantic search capabilities.
`
// Add detailed API documentation to full content
payload.fullContent += `
## Full API Documentation
Detailed API documentation...
`
}
}
})
FAQs
Nuxt module for converting HTML pages to Markdown using mdream
We found that @mdream/nuxt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.