---
title: "Nuxt Config · Nuxt Scripts"
description: "Configure registry scripts, defaults, proxying, privacy, and bundled assets."
canonical_url: "https://scripts.nuxt.com/docs/api/nuxt-config"
meta:
  "og:description": "Configure registry scripts, defaults, proxying, privacy, and bundled assets."
  "og:image": "https://scripts.nuxt.com/_og/s/o_3618b73af171f49e.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Nuxt Config · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_3618b73af171f49e.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Api**

# **Nuxt Config**

[Copy for LLMs](https://scripts.nuxt.com/docs/api/nuxt-config.md)

## `**registry**`

- Type: `**NuxtConfigScriptRegistry**`

Register scripts to prepare their proxy routes, types, bundled assets, and composable auto-imports. An entry loads globally only when it has a `**trigger**`.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      // Infrastructure only (composable driven)
      googleAnalytics: { id: 'G-XXXXXX' },
      // Infrastructure + global auto-load
      plausibleAnalytics: { scriptId: 'YOUR_SCRIPT_ID', trigger: 'onNuxtReady' },
      // Opt out of proxy
      posthog: { apiKey: 'phc_xxx', proxy: false },
      // Testing stub (no script loaded, validation skipped)
      clarity: 'mock',
      // Disable a script
      hotjar: false,
    }
  }
})
```

Per-script capability flags (`**trigger**`, `**proxy**`, `**bundle**`, `**partytown**`, `**privacy**`) can be set at the top level of the config object alongside the script's input fields. For scripts whose proxy support depends on rewriting a bundled SDK, `**bundle: false**` also prevents collection requests from using the proxy. PostHog is the exception: its [`**posthog-js**`** package**](https://posthog.com/docs/libraries/js#option-2-install-via-package-manager) receives the proxy endpoint through `**apiHost**`, so it does not depend on bundling.

Browse the [**Script Registry**](https://scripts.nuxt.com/scripts) for each integration's input and capabilities.

### Environment Variables

The module registers each integration's declared environment-backed fields, such as an analytics ID, token, or API key. Override those fields with `**NUXT_PUBLIC_SCRIPTS_<SCRIPT>_<FIELD>**` environment variables without declaring matching `**runtimeConfig**` keys:

.env

```bash
NUXT_PUBLIC_SCRIPTS_GOOGLE_ANALYTICS_ID=G-XXXXXX
NUXT_PUBLIC_SCRIPTS_POSTHOG_API_KEY=phc_xxx
NUXT_PUBLIC_SCRIPTS_CRISP_ID=your-crisp-id
```

The script must still be present in `**scripts.registry**`. Fields that an integration does not declare for environment use still belong in the registry config. These values are exposed through public runtime config, so do not use this mechanism for server-only secrets.

## `**prefix**`

- Type: `**string**`
- Default: `**'/_scripts'**`

Base path prefix for all script endpoints. Proxy endpoints are served at `**<prefix>/p/****` and bundled assets at `**<prefix>/assets/****`.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    prefix: '/_tracking', // Custom prefix (default: '/_scripts')
  }
})
```

## `**privacy**`

- Type: `**ProxyPrivacyInput**` ( `**boolean | ProxyPrivacy**`)
- Default: `**undefined**` (per-script defaults)

Global privacy override for all proxied scripts. By default, each script uses its own privacy tier declared in the registry. A boolean replaces each per-script default. An object changes only the flags it specifies and preserves the remaining per-script flags.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    // Full anonymization for all proxied traffic
    privacy: true,

    // Or selective override per flag
    privacy: { ip: true },

    // Passthrough (still strips sensitive auth headers)
    privacy: false,
  }
})
```

See the [**First-Party Mode Guide**](https://scripts.nuxt.com/docs/guides/first-party) for details on privacy tiers and per-script overrides.

## `**proxy.alias**`

- Type: `**boolean | Record<string, string>**`
- Default: `**false**`

Replaces real hostnames in first-party proxy paths with generated or explicit aliases. `**true**` generates an opaque alias for every proxied domain. An object maps each domain to its path segment; unlisted domains remain unchanged.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    proxy: {
      alias: {
        'us.i.posthog.com': 'ph',
      }
    }
  }
})
```

## `**proxy.origin**`

- Type: `**string**`
- Default: `**undefined**`

Origin for client-facing proxy URLs: the runtime intercept plugin, build-time bundle rewrites, auto-injected registry endpoints and the Partytown `**resolveUrl**`. Server routes and bundled assets keep their relative paths, so the origin must route `**/_scripts/p/****` (or your `**prefix**`) to this Nuxt server.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    proxy: {
      origin: 'https://t.example.com', // https://t.example.com/_scripts/p/...
    }
  }
})
```

## Partytown (Web Worker) **Experimental**

Load individual scripts in a web worker using [**Partytown**](https://partytown.qwik.dev/). A registry `**trigger**` is still required to generate a global call, but it does not defer the Partytown tag: the current implementation writes that tag into the server-rendered HTML.

nuxt.config.ts

```ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/partytown', '@nuxt/scripts'],
  scripts: {
    registry: {
      plausibleAnalytics: { scriptId: 'YOUR_SCRIPT_ID', partytown: true, trigger: 'onNuxtReady' },
    }
  }
})
```

You must install [`**@nuxtjs/partytown**`](https://github.com/nuxt-modules/partytown). Nuxt auto-configures the `**forward**` array for supported scripts.

### Supported Scripts

Nuxt Scripts configures Partytown forwarding for:

- `**googleAnalytics**`, `**plausibleAnalytics**`, `**cloudflareWebAnalytics**`, `**umamiAnalytics**`, `**matomoAnalytics**`, `**mixpanelAnalytics**`, `**segment**`, `**clarity**`
- `**metaPixel**`, `**xPixel**`, `**tiktokPixel**`, `**snapchatPixel**`, `**redditPixel**`, `**linkedinInsight**`, `**bingUet**`
- `**calendly**`

### Limitations

Partytown is opt-in only for registry scripts with a declared `**partytown**` capability. Setting `**partytown: true**` on any other registry script is ignored with a development warning. The list above describes eligibility for forwarding, not guaranteed compatibility with the current quick path.

**General limitations**:

- The Partytown path preserves only `**src**`; it drops other script attributes, skips registry `**clientInit**`/ `**beforeInit**`, ignores trigger timing, and returns no callable proxy. Several integrations in the forwarding list depend on those omitted attributes or initialization hooks, so test the generated tag and vendor traffic before deploying it.
- `**segment**`, `**mixpanelAnalytics**`, and `**bingUet**` have Partytown forwarding but no collection-proxy capability. If another configured integration activates first-party proxying, Nuxt installs one global `**resolveUrl**` that routes every external worker request through the proxy. Requests to domains outside the proxy allowlist then receive a `**403**`. Avoid that mixed configuration, or provide a custom Partytown `**resolveUrl**` that leaves those hosts direct.
- Worker execution can change timing compared with running on the main thread
- Calls that application code makes on forwarded globals must be listed in Partytown's [`**forward**`** configuration**](https://partytown.qwik.dev/forwarding-events/)
- If you provide a custom Partytown `**resolveUrl**`, add the Nuxt Scripts proxy routing rules yourself

## `**defaultScriptOptions**`

- Type: `**NuxtUseScriptOptions**`
- Default: `**{ trigger: 'onNuxtReady' }**`

Defaults inherited by each script. The [`**useScript()**`** reference**](https://scripts.nuxt.com/docs/api/use-script) lists the available options.

## `**globals**`

- Type: `**Record<string, NuxtUseScriptInput | [NuxtUseScriptInput, NuxtUseScriptOptionsSerializable]>**`
- Default: `**{}**`

Scripts registered on every page through [`**useScript()**`](https://scripts.nuxt.com/docs/api/use-script).

The [**Globals guide**](https://scripts.nuxt.com/docs/guides/global) covers tuples, environment overrides, and `**$scripts**` access.

## `**defaultScriptOptions.warmupStrategy**`

- Type: `**false | 'preload' | 'preconnect' | 'dns-prefetch'**`
- Default: `**'preload'**` for scripts with `**onNuxtReady**` or `**client**` triggers; no automatic warmup otherwise

Controls how the browser warms up connections to script origins before the script loads. MDN's [**speculative loading guide**](https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/Speculative_loading) compares the cost and intended use of each resource hint:

- `**'preload'**` inserts a `**<link rel="preload">**` tag and downloads a script that will load soon.
- `**'preconnect'**` completes DNS, TCP, and TLS setup for a script that will load later.
- `**'dns-prefetch'**` resolves only DNS, without downloading the script.
- `**false**` disables warmup entirely. Use when you bundle scripts and serve them from your own domain.

When [**first-party mode**](https://scripts.nuxt.com/docs/guides/first-party) bundles scripts, `**preconnect**` and `**dns-prefetch**` automatically fall back to `**false**` since your origin already serves the script.

## `**enabled**`

- Type: `**boolean**`
- Default: `**true**`

Set `**false**` to disable the Nuxt Scripts module.

## `**debug**`

- Type: `**boolean**`
- Default: `**false**`

Set `**true**` to print debug logs.

## `**assets**`

- Type: `**object**`
- Default: `**{ fetchOptions: { retry: 3, retryDelay: 2000, timeout: 15_000 } }**`

Controls how Nuxt bundles scripts for serving. The only supported `**strategy**` is currently `**'public'**`.

The [**First-Party Mode guide**](https://scripts.nuxt.com/docs/guides/first-party) explains the build cache and fallback behavior.

## `**assets.fallbackOnSrcOnBundleFail**`

- Type: `**boolean**`
- Default: `**false**`

Falls back to the remote `**src**` URL when bundling fails. By default, the bundling process stops if the third-party script cannot be downloaded.

## `**assets.fetchOptions**`

- Type: `**object**`
- Default: `**{ retry: 3, retryDelay: 2000, timeout: 15_000 }**`

Options to pass to the fetch function when downloading scripts.

## `**assets.cacheMaxAge**`

- Type: `**number**`
- Default: `**604800000**` (7 days)

Cache duration for bundled scripts in milliseconds. Scripts older than this will be re-downloaded during builds.

## `**assets.integrity**`

- Type: `**boolean | 'sha256' | 'sha384' | 'sha512'**`
- Default: `**false**`

Generates a Subresource Integrity (SRI) hash for each bundled script and adds `**integrity**` with `**crossorigin="anonymous"**`.

Browsers compare the downloaded script with its declared hash before executing it; see MDN's [**Subresource Integrity**](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Subresource_Integrity) guide.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/3.api/5.nuxt-config.md)

[Markdown For LLMs](https://scripts.nuxt.com/docs/api/nuxt-config.md)

[**useScriptEventPage()** React to changes in the current page title or path.](https://scripts.nuxt.com/docs/api/use-script-event-page) [**Nuxt App Hooks** Inspect scripts in development or change declared globals at runtime.](https://scripts.nuxt.com/docs/api/nuxt-app-hooks)

**On this page **

- [registry](#registry)
- [prefix](#prefix)
- [privacy](#privacy)
- [proxy.alias](#proxyalias)
- [proxy.origin](#proxyorigin)
- Partytown (Web Worker) Experimental
- [defaultScriptOptions](#defaultscriptoptions)
- [globals](#globals)
- [defaultScriptOptions.warmupStrategy](#defaultscriptoptionswarmupstrategy)
- [enabled](#enabled)
- [debug](#debug)
- [assets](#assets)
- [assets.fallbackOnSrcOnBundleFail](#assetsfallbackonsrconbundlefail)
- [assets.fetchOptions](#assetsfetchoptions)
- [assets.cacheMaxAge](#assetscachemaxage)
- [assets.integrity](#assetsintegrity)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/docs/api/nuxt-config#webpage","@type":"WebPage","description":"Configure registry scripts, defaults, proxying, privacy, and bundled assets.","name":"Nuxt Config","url":"https://scripts.nuxt.com/docs/api/nuxt-config","breadcrumb":{"@id":"https://scripts.nuxt.com/docs/api/nuxt-config#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/docs/api/nuxt-config"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/docs/api/nuxt-config#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Documentation","item":"https://scripts.nuxt.com/docs","position":2},{"@type":"ListItem","name":"API","item":"https://scripts.nuxt.com/docs/api","position":3},{"@type":"ListItem","name":"Nuxt Config","item":"https://scripts.nuxt.com/docs/api/nuxt-config","position":4}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
