---
title: "Nuxt App Hooks · Nuxt Scripts"
description: "Inspect scripts in development or change declared globals at runtime."
canonical_url: "https://scripts.nuxt.com/docs/api/nuxt-app-hooks"
meta:
  "og:description": "Inspect scripts in development or change declared globals at runtime."
  "og:image": "https://scripts.nuxt.com/_og/s/o_0f228584d0d0f29e.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Nuxt App Hooks · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_0f228584d0d0f29e.png"
---

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

**Api**

# **Nuxt App Hooks**

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

## `**scripts:updated**`

- Type: `**(ctx: { scripts: Record<string, NuxtDevToolsScriptInstance> }) => void | Promise<void>**`

Triggered in development when Nuxt Scripts updates the DevTools snapshot for a script. The payload includes lifecycle events and captured resource timing entries.

Nuxt Scripts uses this hook internally for DevTools. It is not emitted in production builds.

plugins/nuxt-scripts.ts

```ts
export default defineNuxtPlugin({
  setup() {
    useNuxtApp().hooks.hook('scripts:updated', (ctx) => {
      console.log('Scripts updated', ctx.scripts)
    })
  }
})
```

## `**scripts:globals**`

- Type: `**(globals: Record<string, Record<string, any>>) => void | Promise<void>**`

Runs in the generated `**scripts:init**` plugin immediately before it registers `**scripts.globals**`. The mutable `**globals**` map contains each declared key with build-time defaults merged with any `**NUXT_PUBLIC_SCRIPTS_GLOBALS_***` environment overrides. Change an entry's `**src**` or attributes, or delete the entry, without rebuilding.

Static declarations keep their `**$scripts**` types and remain eligible for asset bundling. Deleting an entry, setting `**enabled: false**`, or clearing its `**src**` skips registration, and its `**$scripts**` value is `**undefined**`. The hook cannot add undeclared keys; call [`**useScript()**`](https://scripts.nuxt.com/docs/api/use-script) from your own plugin for those.

Register the listener in an `**enforce: 'pre'**` plugin so it runs before `**scripts:init**`.

plugins/nuxt-scripts-globals.ts

```ts
export default defineNuxtPlugin({
  enforce: 'pre',
  setup(nuxtApp) {
    const { tenant } = useRuntimeConfig().public
    nuxtApp.hooks.hook('scripts:globals', (globals) => {
      // Drop an integration this tenant doesn't use:
      if (!tenant.awinEnabled)
        delete globals.awin
      // Compute the src from runtime config:
      globals.trustedShops.src = `https://widgets.trustedshops.com/${tenant.trustedShopsId}.js`
    })
  }
})
```

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

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

[**Nuxt Config** Configure registry scripts, defaults, proxying, privacy, and bundled assets.](https://scripts.nuxt.com/docs/api/nuxt-config) [**Nuxt Hooks** Add registry scripts from a Nuxt module at build time.](https://scripts.nuxt.com/docs/api/nuxt-hooks)

**On this page **

- [scripts:updated](#scriptsupdated)
- [scripts:globals](#scriptsglobals)

```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-app-hooks#webpage","@type":"WebPage","description":"Inspect scripts in development or change declared globals at runtime.","name":"Nuxt App Hooks","url":"https://scripts.nuxt.com/docs/api/nuxt-app-hooks","breadcrumb":{"@id":"https://scripts.nuxt.com/docs/api/nuxt-app-hooks#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/docs/api/nuxt-app-hooks"]}],"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-app-hooks#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 App Hooks","item":"https://scripts.nuxt.com/docs/api/nuxt-app-hooks","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.
