|
5 | 5 | [![License][license-src]][license-href] |
6 | 6 | [![Nuxt][nuxt-src]][nuxt-href] |
7 | 7 |
|
8 | | -Easily detect Performance, Hydration, and Security issues in your Nuxt application ! |
| 8 | +**A Nuxt module that provides real-time feedback on your application's performance, accessibility, and security right in your browser.** |
9 | 9 |
|
10 | | -- [✨ Release Notes](/CHANGELOG.md) |
| 10 | +Nuxt Hints integrates directly into the Nuxt DevTools, giving you actionable insights to improve your web vitals, fix hydration mismatches, and audit third-party scripts without ever leaving your development environment. |
| 11 | + |
| 12 | +- [✨Release Notes](/CHANGELOG.md) |
11 | 13 |
|
12 | 14 | ## Features |
13 | 15 |
|
14 | | -### 🚀 **Performance Analysis** |
15 | | -- **LCP (Largest Contentful Paint) Optimization**: Identifies images that could benefit from modern formats (WebP, AVIF), proper sizing, fetch priority, and preloading |
16 | | -- **CLS (Cumulative Layout Shift) Detection**: Warns about layout shifts caused by images without dimensions |
17 | | -- **Loading Performance**: Tracks and reports slow-loading elements (>2.5s) |
18 | | -- **Image Best Practices**: Validates proper `width`, `height`, `loading`, and `fetchPriority` attributes |
| 16 | +- **🚀 Rich DevTools UI**: A dedicated tab in Nuxt DevTools to visualize issues, inspect elements, and get recommendations. |
| 17 | +- **💧 Hydration Mismatch Debugging**: Side-by-side diffing of server-rendered and client-hydrated HTML to pinpoint the exact cause of mismatches. |
| 18 | +- **⚡️ Web Vitals Analysis**: Real-time metrics for LCP, INP, and CLS with detailed attribution and element-specific optimization tips. |
| 19 | +- **📦 Third-Party Script Auditing**: Dashboard to monitor performance, identify render-blocking scripts, and get security recommendations. |
| 20 | +- **🔍 Interactive Diagnostics**: |
| 21 | + - **Hover to Highlight**: Hover over an issue in the DevTools to highlight the corresponding element on your page. |
| 22 | + - **Click to Inspect**: Click to open the component source file directly in your code editor. |
| 23 | +- **💡 Actionable Console Warnings**: Clear, concise console messages that guide you to best practices and performance improvements. |
19 | 24 |
|
20 | | -### 📦 **Third-Party Script Monitoring** |
21 | | -- **Script Detection**: Automatically identifies third-party scripts on your pages |
22 | | -- **Performance Tracking**: Measures load times for external scripts with detailed timing breakdowns |
23 | | -- **Security Recommendations**: Suggests adding `crossorigin="anonymous"` for better security and error reporting |
24 | | -- **@nuxt/scripts Integration**: Recommends using `@nuxt/scripts` for better third-party script management |
| 25 | +## Visual Interface within Devtools |
25 | 26 |
|
26 | | -### 💧 **Hydration Insights** |
27 | | -- **SSR/Client Mismatch Detection**: Helps identify hydration issues between server and client rendering |
| 27 | +Nuxt Hints provides a rich, interactive UI inside the Nuxt DevTools panel. |
28 | 28 |
|
29 | | -### 🛠️ **Developer Experience** |
30 | | -- **Nuxt DevTools Integration**: Rich UI for visualizing performance issues and recommendations |
31 | | -- **Console Warnings**: Clear, actionable messages with links to web.dev documentation |
| 29 | +### Homepage |
32 | 30 |
|
33 | | -## Quick Setup |
| 31 | +A central hub to see a summary of all detected issues at a glance. |
34 | 32 |
|
35 | | -### Quick install using nuxt CLI |
| 33 | + |
36 | 34 |
|
37 | | -1. run `npx nuxt module add @nuxt/hints` |
| 35 | +### Web Vitals |
38 | 36 |
|
39 | | -### Manual install |
| 37 | +Drill down into Core Web Vitals metrics. See detailed attribution for LCP, INP, and CLS, inspect the problematic elements, and get context-aware advice. |
40 | 38 |
|
41 | | -1. Add `@nuxt/hints` dependency to your project |
| 39 | + |
42 | 40 |
|
43 | | -```bash |
44 | | -# Using pnpm |
45 | | -pnpm add -D @nuxt/hints |
| 41 | +### Hydration Inspector |
46 | 42 |
|
47 | | -# Using yarn |
48 | | -yarn add --dev @nuxt/hints |
| 43 | +Debug hydration mismatches with a powerful side-by-side diff viewer. See the exact differences between the server-rendered HTML and the client-side result. |
49 | 44 |
|
50 | | -# Using npm |
51 | | -npm install --save-dev @nuxt/hints |
52 | | -``` |
| 45 | + |
53 | 46 |
|
54 | | -2. Add `@nuxt/hints` to the `modules` section of `nuxt.config.ts` |
| 47 | +### Third-Party Scripts |
55 | 48 |
|
56 | | -```js |
57 | | -export default defineNuxtConfig({ |
58 | | - modules: ["@nuxt/hints"], |
59 | | -}); |
60 | | -``` |
| 49 | +Analyze all third-party scripts on your page. The dashboard shows loading times, render-blocking status, and security attributes, helping you identify and mitigate performance bottlenecks. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +## Quick Setup |
| 54 | + |
| 55 | +1. Add `@nuxt/hints` dependency to your project: |
| 56 | + ```bash |
| 57 | + # Using pnpm |
| 58 | + pnpm add -D @nuxt/hints |
61 | 59 |
|
62 | | -That's it! You can now use Nuxt Hints in your Nuxt app ✨ |
| 60 | + # Using yarn |
| 61 | + yarn add --dev @nuxt/hints |
| 62 | + |
| 63 | + # Using npm |
| 64 | + npm install --save-dev @nuxt/hints |
| 65 | + ``` |
| 66 | + |
| 67 | +2. Add `@nuxt/hints` to the `modules` section of `nuxt.config.ts`: |
| 68 | + ```js |
| 69 | + export default defineNuxtConfig({ |
| 70 | + modules: [ |
| 71 | + '@nuxt/hints' |
| 72 | + ] |
| 73 | + }) |
| 74 | + ``` |
| 75 | + |
| 76 | +That's it! Open your Nuxt app, go to the DevTools, and click the Nuxt Hints icon to get started. |
63 | 77 |
|
64 | 78 | ## How It Works |
65 | 79 |
|
66 | 80 | ### Performance Monitoring |
| 81 | +Nuxt Hints uses `web-vitals` to gather Core Web Vitals metrics and automatically logs any metrics that need improvement. It listens for INP, LCP, and CLS and provides detailed attribution for each. |
67 | 82 |
|
68 | | -Nuxt Hints uses the **Performance Observer API** to monitor your application. |
| 83 | +### Hydration Mismatch Detection |
| 84 | +The module hooks into Vue's hydration process to compare the server-rendered DOM with the client-side DOM. When a mismatch is detected, it captures the pre- and post-hydration HTML for inspection. |
69 | 85 |
|
70 | 86 | ### Third-Party Script Analysis |
71 | | - |
72 | | -The module automatically detects and analyzes third-party scripts. |
| 87 | +Using a combination of a Nitro plugin and client-side observers, Nuxt Hints tracks every script loaded on the page, measuring its performance and analyzing its attributes. |
73 | 88 |
|
74 | 89 | ### Example Console Output |
75 | | - |
76 | | -When Nuxt Hints detects issues, you'll see warnings in console like: |
| 90 | +When Nuxt Hints detects issues, you'll see clear warnings in your browser console: |
77 | 91 |
|
78 | 92 | ``` |
79 | 93 | [@nuxt/hints:performance] LCP Element should not have `loading="lazy"` |
80 | 94 | Learn more: https://web.dev/optimize-lcp/#optimize-the-priority-the-resource-is-given |
81 | 95 | ``` |
82 | 96 |
|
83 | 97 | ``` |
84 | | -[@nuxt/hints:performance] LCP Element can be served in a next gen format like `webp` or `avif` |
85 | | -Learn more: https://web.dev/choose-the-right-image-format/ |
86 | | -Use: https://image.nuxt.com/usage/nuxt-img#format |
87 | | -``` |
88 | | - |
89 | | -``` |
90 | | -[@nuxt/hints] Third-party script "https://cdn.example.com/script.js" is missing crossorigin attribute. |
| 98 | +[@nuxt/hints] Third-party script "https://cdn.example.com/script.js" is missing crossorigin attribute. |
91 | 99 | Consider adding crossorigin="anonymous" for better security and error reporting. |
92 | 100 | ``` |
93 | 101 |
|
@@ -118,7 +126,6 @@ npm run release |
118 | 126 | ``` |
119 | 127 |
|
120 | 128 | <!-- Badges --> |
121 | | - |
122 | 129 | [npm-version-src]: https://img.shields.io/npm/v/@nuxt/hints/latest.svg?style=flat&colorA=18181B&colorB=28CF8D |
123 | 130 | [npm-version-href]: https://npmjs.com/package/@nuxt/hints |
124 | 131 | [npm-downloads-src]: https://img.shields.io/npm/dm/@nuxt/hints.svg?style=flat&colorA=18181B&colorB=28CF8D |
|
0 commit comments