CLI tool
nuxt/scripts avatar
nuxt/scripts

Nuxt Scripts: third-party scripts with triggers, consent and a script registry

Third-Party Scripts Meets Nuxt Developer Experience.

584 stars95 forksTypeScriptMIT

At a glance

What is it?
Nuxt Scripts is a Nuxt module that wraps third-party script loading with fine-grained triggers, consent management, self hosting and a registry of pre-configured integrations, built on Unhead's script loading and shipping a runtime of about two kilobytes with no dependencies. The 2.0 line is in beta.
Who is it for?
Adopt Nuxt Scripts if you maintain a Nuxt application with several third-party scripts and want to control when each one loads, keep consent decisions honest, and stop maintaining ad-hoc useHead blocks. Skip it if your project has one or two analytics tags, since the module would be more machinery than the problem deserves, and skip it if you cannot accept a beta dependency in production.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 24, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem is that useHead is fine until it is not

The background section states the problem plainly. Loading third-party IIFE scripts using the useHead composable is easy, however things start getting more complicated quickly around SSR, lazy loading and type safety. Nuxt Scripts solves these issues and more with the goal of making third-party scripts more performant, have better privacy and be better DX overall. That framing is accurate about what breaks. A script tag in useHead is rendered into the HTML during server rendering, which means the third party gets a request on the server's behalf before the user has interacted with anything, and the same tag has no way to express that it should wait until consent, or until a particular element exists, or until the user scrolls. The SSR problem is worse than it looks, because a script that was meant to be lazy can end up blocking the first render. The library's answer is a layer above the head manager that knows about triggers, consent state and loading strategy, and it does so without asking you to give up the head API you already use.

Built on Unhead's script loading

The first feature listed is that the module is built on top of Unhead Script Loading, which is the script loading portion of the Unhead library. That choice matters because it means Nuxt Scripts is not a parallel head implementation but an extension of the one Nuxt already ships. The features it inherits and improves are grouped under performance, privacy and developer experience. For performance there is self hosting, advanced script loading triggers and best-practice defaults. For privacy there are defaults that protect the end user's identity and script consent management APIs. For developer experience there is a DevTools view where you can see your script with its status and see function logs. The last of those is the kind of feature that decides whether a team keeps using a tool, because the alternative when a third-party script silently fails to load is to open devtools, find the tag by hand and guess. The scale claim is modest and specific, zero dependencies and an approximately two kilobyte minimal runtime, which for a module that sits in the critical rendering path is a reasonable thing to have measured.

Installing it and what the module add actually does

The quick start is a single command.

bash
npx nuxi@latest module add scripts

That is the Nuxt module installer, and the README's explanation of what happens afterwards is short, that the module should be downloaded and added to your Nuxt Config modules. So there is no manual configuration step to get past before you see a script load, which is the point of the nuxi module add convention. The npm package is @nuxt/scripts, published from a monorepo named nuxt-scripts-monorepo, and the package is marked private with a version of 2.0.0-beta.16, so the version you install is a beta. The engines field is worth reading because it is specific.

json
  "engines": {
    "node": "^22.22.3 || ^24.15.0 || >=26.0.0"
  },

That is a narrow set of Node versions, requiring a patched 22.22, a patched 24.15 or anything at or above 26. The reason is almost certainly the Unhead and Vite toolchain underneath, but the practical effect is that a team on an unpatched Node 22 line cannot install it. There is also a Volta badge in the README, so the project expects a managed Node version, and a tip for agents, pointing at a skill for the module published on skilld.dev, which tells you the project is investing in making the module usable from an AI coding agent.

The registry is the part that saves you the most work

The feature list says twenty or more third-party script integrations with fine-grained performance optimisations, and the examples directory names several of the kinds of script that are awkward to load by hand. There is a cookie consent example using Google Consent Mode v2 with GTM, a granular consent example for per-category consent management, a custom script example for integrating any third-party script, and a performance example for optimising loading with triggers. The repository listing shows the same set as directories, with the addition of a regional-consent example, and the test fixtures in the root package.json give a longer list of the specific integrations the project maintains, among them cdn and partytown variants, a first-party fixture, a linkedin-insight fixture with a cdn variant, a tiktok-pixel fixture, calendly with a cdn variant, ahrefs-analytics with a cdn variant, usercentrics, speedcurve and maplibre. That fixture list is more informative than the marketing number, because it shows that the module is not just a wrapper but a set of tuned loading strategies for particular vendors, including whether each script is best loaded from your own origin or from a CDN. The registry is also browsable online as a list of popular pre-configured third-party scripts, and there is a global scripts guide for scripts that should apply to the whole application rather than to a page.

Triggers, consent and bundling are where the behaviour lives

The next steps section links the documentation topics that describe the actual mechanisms, and their names give you the feature set. Script Loading and script triggers is the guide to how a script decides to load, and it is the feature the performance claim rests on, since a script that loads on idle or on interaction costs much less than one that blocks the first render. Bundling is the guide for fine-tuning performance, and the idea is that a third-party script can be bundled into your own output rather than fetched from a vendor origin, which removes a third party connection and a DNS lookup and a TLS handshake from the critical path. Consent Management is the other guide, and it covers the privacy side, where the module defaults to protecting the end user's identity and exposes APIs so your own consent banner can drive which scripts load. The examples reinforce that this is a two-sided tool, with the granular consent example doing per-category management and the regional consent example directory suggesting consent rules that vary by the user's region. The combination of these three is what the module is actually selling, since a trigger without consent lets a script fire before the user has agreed to it, and consent without a trigger means you are still loading scripts you never use.

Where Nuxt Scripts is the wrong tool

There are clear cases where this module is more than you need. If your application loads one analytics script, a useHead entry is entirely adequate and adding a module, a registry and a consent API buys nothing. If your scripts are loaded by a tag manager that you control well, this module overlaps with the tag manager's own consent and trigger features, and running both means two places to reason about. The second limit is the beta. The 2.0 line is in beta with the tags v2.0.0-beta.14, beta.15 and beta.16 all published on consecutive days in October 2026, which tells you the API is still moving and that you would be adopting something in flux, and for a module whose job is to be trusted with consent decisions and third-party loading, that instability is a real cost. The third is the Node constraint, since the engines field excludes a lot of deployed environments. The fourth is conceptual. The module's value assumes you want to load fewer scripts, later, and from your own origin. If your requirement is the opposite, for example a marketing team that needs a tag deployed on every page within a minute of a dashboard click, the trigger model and the self hosting model work against you rather than for you, and a tag manager is the better answer.

Editorial conclusion

Adopt Nuxt Scripts if you maintain a Nuxt application with several third-party scripts and want to control when each one loads, keep consent decisions honest, and stop maintaining ad-hoc useHead blocks. Skip it if your project has one or two analytics tags, since the module would be more machinery than the problem deserves, and skip it if you cannot accept a beta dependency in production. Verify first which of the twenty or more registry integrations covers your scripts, that your Node version satisfies the engines range, and how the consent API behaves when a user declines, since that path is where privacy bugs hide.

Frequently asked questions

What problem does Nuxt Scripts solve in a Nuxt app?

Loading third-party IIFE scripts with the useHead composable is easy, but things get complicated quickly around SSR, lazy loading and type safety. Nuxt Scripts adds loading triggers, consent management and self hosting on top of Unhead's script loading, with defaults that protect the end user's identity.

How do I add the Nuxt Scripts module to a project?

Run npx nuxi@latest module add scripts, which downloads the module and adds it to your Nuxt config modules. The npm package is @nuxt/scripts, and the module requires Node 22.22.3, 24.15.0 or 26 and above according to its engines field.

What does the Nuxt Scripts registry offer?

The module ships twenty or more pre-configured third-party script integrations, with a registry browsable online, and the repository includes examples for cookie consent with Google Consent Mode v2, granular and regional consent, custom scripts and performance tuning with triggers, alongside test fixtures for specific vendors such as tiktok-pixel, calendly, ahrefs-analytics, usercentrics, speedcurve and maplibre.

Official sources

  1. License: MIT
  2. nuxt/scripts on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nuxt-scripts.svg)](https://hysenlabs.com/projects/nuxt-scripts)

Was this useful?