

This module configures html-validate to automatically validate Nuxt server-rendered HTML (SSR and SSG) to detect common issues with HTML that can lead to hydration errors, as well as improve accessibility and best practice.
npx nuxi@latest module add html-validator
defineNuxtConfig({
modules: ['@nuxtjs/html-validator']
})
html-validator won't be added to your production bundle - it's just used in development and at build/generate time.@nuxtjs/html-validator takes four options.
usePrettier enables prettier printing of your source code to show errors in-context.logLevel sets the verbosity to one of verbose, warning or error. It defaults to verbose in dev, and warning when generating.No HTML validation errors found for ... message.failOnError will throw an error after running nuxt generate if there are any validation errors with the generated pages.options allows you to pass in html-validate options that will be merged with the default configurationhtml-validatehere.Defaults
{
htmlValidator: {
usePrettier: false,
logLevel: 'verbose',
failOnError: false,
/** A list of routes to ignore (that is, not check validity for). */
ignore: [/\.(xml|rss|json)$/],
options: {
extends: [
'html-validate:document',
'html-validate:recommended',
'html-validate:standard'
],
rules: {
'svg-focusable': 'off',
'no-unknown-elements': 'error',
// Conflicts or not needed as we use prettier formatting
'void-style': 'off',
'no-trailing-whitespace': 'off',
// Conflict with Nuxt defaults
'require-sri': 'off',
'attribute-boolean-style': 'off',
'doctype-style': 'off',
// Unreasonable rule
'no-inline-style': 'off'
}
}
}
}
You're good to go!
Every time you hard-refresh (server-render) a page in Nuxt, you will see any HTML validation issues printed in your server console.