Load Third-Party Scripts in Nuxt · Nuxt Scripts
Index of every page on this site: llms.txt Skip to main content v1 stable is here Load Third-Party Scripts with Nuxt Scripts Load third-party scripts with better performance, privacy, security and DX. Includes many popular third-parties out of the box. Get started Star on GitHub Better Web Vitals Load scripts when they're needed with best practices non-blocking the rendering of your Nuxt app by default. Privacy for your users Avoid leaking user data to third-party scripts that don't need it.
Ensure your scripts are GDPR compliant. Secure third-parties Protect your app from third-party scripts that could be compromised. A powerful API with just enough magic Nuxt Scripts provides an abstraction layer on top of third-party scripts, providing SSR support and type-safety while still giving you full low-level control over how a script is loaded. app.vue const { proxy } = useScript ( '/tracker.js' , { trigger : 'onNuxtReady' , use () { return { trackEvent : window. trackEvent } } }) // fully typed, SSR safe proxy . trackEvent ( 'page_view' ) Speed up with Facade Components Nuxt Scripts provides several Facade Components out of the box.
Facade components are fake UI elements that get replaced once a third-party script loads, they can significantly improve your performance while still providing a great user experience, however they do have trade-offs . Google Maps Nuxt Scripts 11.9x Faster 70ms Iframe 830ms YouTube Nuxt Scripts 46.4x Faster 70ms Iframe 3.3s Vimeo Nuxt Scripts 3.7x Faster 70ms Iframe 260ms Intercom Nuxt Scripts 3.9x Faster 220ms Iframe 850ms *Note that PageSpeed Insights lab data is a snapshot from a particular day, which tends to be variable.
Cookie consent, typed per vendor Every consent-aware script returns a consent object matching the vendor's native API, paired with defaultConsent applied before the first call. Google Consent Mode v2, Meta grant/revoke, Matomo give/forget, TikTok three-state and more. Bridge OneTrust or Cookiebot, or ship your own banner with useScriptTriggerConsent . consent.ts const { consent } = useScriptGoogleAnalytics ({ id : 'G-XXXXXXXX' , defaultConsent : { ad_storage : 'denied' , analytics_storage : 'denied' , }, }) // Google Consent Mode v2 consent . update ({ ad_storage : 'granted' , analytics_storage : 'granted' , }) Privacy-first social embeds Embed posts from X, Instagram, and Bluesky without loading third-party scripts.
All content is fetched server-side and proxied through your domain. Zero client-side JavaScript, zero cookies, zero third-party requests. Privacy and performance comparison between Nuxt Scripts and native social embeds Nuxt Scripts vs Native X Instagram Bluesky Client JS 0 vs 475 KB 0 vs 580 KB 0 vs 42 KB Requests 0 vs 25 0 vs 34 0 vs 9 Cookies No vs Yes No vs Yes No vs No Blocking Time 0ms vs 1,010ms 0ms vs 780ms 0ms vs 60ms Live social embed demos Live social demos load when this section approaches the viewport.
Watch the intro videos from the pros. A faster web collaboration Nuxt Scripts was designed and built by the Nuxt core team in collaboration with the Chrome Aurora team at Google. Nuxt Scripts is being actively maintained by the Nuxt core team and amazing community contributors, we welcome all contributions. Community Funded Nuxt Scripts is free and open-source thanks to generous community sponsors. Become a sponsor Top Sponsors Daniel Roe Jan-Henrik Damaschke Gold Sponsors Backers Try out our JS Confetti Tutorial Learn all of the fundamentals of Nuxt Scripts in the fun interactive confetti tutorial.
Get started