Skip to content

Commit b45023d

Browse files
authored
docs(readme): clarify prefetch via client bundle (#465)
1 parent 33be9b6 commit b45023d

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ export default defineNuxtConfig({
228228
})
229229
```
230230

231+
#### Disabling Runtime Fetching
232+
231233
Or if you want to disable the dynamic icon fetching completely and only use icons from the [client bundle](#client-bundle), you can set `provider: 'none'`:
232234

233235
```ts
@@ -446,6 +448,51 @@ This will make requests to Iconify API every time the client requests an icon. W
446448

447449
For icons that you know you are going to use frequently, you can bundle them with your client bundle to avoid network requests.
448450

451+
#### Prefetch (Preload) Icons
452+
453+
If you want icons to be available on first render, use the client bundle as the prefetch mechanism:
454+
455+
```ts
456+
export default defineNuxtConfig({
457+
modules: [
458+
'@nuxt/icon',
459+
],
460+
icon: {
461+
clientBundle: {
462+
// Explicitly pre-bundle known icons
463+
icons: ['uil:github', 'heroicons:home'],
464+
// Keep disabled if you only want explicit entries
465+
scan: false,
466+
},
467+
},
468+
})
469+
```
470+
471+
You can also enable static scanning to pre-bundle icons referenced literally in your source files:
472+
473+
```ts
474+
export default defineNuxtConfig({
475+
modules: [
476+
'@nuxt/icon',
477+
],
478+
icon: {
479+
clientBundle: {
480+
// Automatically includes statically-detected icon usages
481+
scan: true,
482+
// Keep explicit entries for dynamic icon names
483+
icons: ['uil:github'],
484+
},
485+
},
486+
})
487+
```
488+
489+
If you want to disable runtime icon fetching entirely, see [Disabling Runtime Fetching](#disabling-runtime-fetching) for the `provider: 'none'` + client bundle pattern.
490+
491+
> [!TIP]
492+
> Static scanning only detects literal icon names. See [Scan Components](#scan-components) for details and examples, and [Rendering Icons in Component Tests](#rendering-icons-in-component-tests) for test-environment setup.
493+
494+
#### Available Options
495+
449496
```ts
450497
export default defineNuxtConfig({
451498
modules: [

0 commit comments

Comments
 (0)