run_nextjs_audit
Audit Next.js applications for performance, SEO, and accessibility issues using automated browser testing on ARM64 devices.
Instructions
Run a Next.js specific audit on the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:988-1027 (handler)The core handler function for the 'run_nextjs_audit' tool. It evaluates JavaScript in the browser context to check for Next.js-specific optimizations such as use of Image component, Link for internal navigation, and Head component.async runNextJSAudit() { await this.ensureChromium(); const result = await this.sendCDPCommand('Runtime.evaluate', { expression: ` const results = []; const nextData = document.querySelector('#__NEXT_DATA__'); if (!nextData) { results.push('This does not appear to be a Next.js application'); JSON.stringify(results); } else { const nextImages = document.querySelectorAll('img[data-nimg]'); const regularImages = document.querySelectorAll('img:not([data-nimg])'); if (regularImages.length > 0 && nextImages.length === 0) { results.push(\`Consider using Next.js Image component for \${regularImages.length} images\`); } const internalLinks = Array.from(document.querySelectorAll('a[href^="/"]')).length; if (internalLinks > 0) { results.push(\`Found \${internalLinks} internal links - ensure Next.js Link component is used\`); } const headTags = document.querySelectorAll('meta, title, link[rel="stylesheet"]'); if (headTags.length < 3) { results.push('Consider using Next.js Head component for better SEO'); } JSON.stringify(results.length > 0 ? results : ['Next.js specific checks passed']); } `, returnByValue: true }); const nextjsResults = JSON.parse(result.result?.value || '[]'); return { content: [{ type: 'text', text: `Next.js Audit Results:\\n${nextjsResults.join('\\n')}` }], }; }
- index.js:311-318 (registration)Registration of the 'run_nextjs_audit' tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: 'run_nextjs_audit', description: 'Run a Next.js specific audit on the current page', inputSchema: { type: 'object', properties: {}, }, },
- index.js:314-317 (schema)Input schema for the 'run_nextjs_audit' tool, which takes no parameters (empty properties).inputSchema: { type: 'object', properties: {}, },
- index.js:387-388 (handler)Dispatch case in the generic CallToolRequestSchema handler that routes calls to the specific runNextJSAudit method.case 'run_nextjs_audit': return await this.runNextJSAudit();