---
title: "useScript · Nuxt Scripts"
description: "API documentation for the useScript function."
canonical_url: "https://scripts.nuxt.com/docs/v0/api/use-script"
meta:
  "og:description": "API documentation for the useScript function."
  "og:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_useScript%2Cdescription_API%2Bdocumentation%2Bfor%2Bthe%2BuseScript%2Bfunction.%2Cheadline_Api%2Cp_Ii9kb2NzL3YwL2FwaS91c2Utc2NyaXB0Ig%2Cs_On4MNq2isn99-vR1.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "useScript · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/d/c_Docs%2Ctitle_useScript%2Cdescription_API%2Bdocumentation%2Bfor%2Bthe%2BuseScript%2Bfunction.%2Cheadline_Api%2Cp_Ii9kb2NzL3YwL2FwaS91c2Utc2NyaXB0Ig%2Cs_On4MNq2isn99-vR1.png"
---

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

**Api**

# **useScript**

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

This composable is a wrapper around the Unhead [**useScript**](https://unhead.unjs.io/usage/composables/use-script) with extra Nuxt goodies on top, for full documentation please refer to this.

## Signature

```ts
export function useScript<T extends Record<string | symbol, any>>(input: UseScriptInput, options?: NuxtUseScriptOptions): T & { $script: Promise<T> & VueScriptInstance<T> } {}
```

## Arguments

### `**UseScriptInput**`

This is the script tag input. For example, you can pass a URL string or an object with the script tag attributes.

```ts
export type UseScriptInput = string | {
  src?: string
  async?: boolean
  defer?: boolean
  type?: string
  integrity?: string
  crossorigin?: string
  text?: string
  innerHTML?: string
  innerText?: string
  content?: string
  referrerPolicy?: string
  attributes?: Record<string, string>
}
```

See the [**Script Input**](https://unhead.unjs.io/usage/composables/use-script#argument-script-options) documentation for more information on the options.

### `**NuxtUseScriptOptions**`

See the [**Script Options**](https://unhead.unjs.io/usage/composables/use-script#argument-use-script-options) documentation for more information on the options.

- `**use**` - The function to resolve the script.
- `**trigger**` - [**Triggering Script Loading**](https://scripts.nuxt.com/docs/v0/guides/script-triggers)
- `**bundle**` - [**Bundling Remote Scripts**](https://scripts.nuxt.com/docs/v0/guides/bundling) for more information.

```ts
export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
  /**
   * The trigger to load the script:
   * - `onNuxtReady` - Load the script when Nuxt is ready.
   * - `manual` - Load the script manually by calling `load()`
   * - `Promise` - Load the script when the promise resolves.
   */
  trigger?: UseScriptOptions<T>['trigger'] | 'onNuxtReady'
  /**
   * Should the script be bundled as an asset and loaded from your server. This is useful for improving the
   * performance by avoiding the extra DNS lookup and reducing the number of requests. It also
   * improves privacy by not sharing the user's IP address with third-party servers.
   * - `true` - Bundle the script as an asset.
   * - `false` - Do not bundle the script. (default)
   */
  bundle?: boolean
  /**
   * Skip any schema validation for the script input. This is useful for loading the script stubs for development without
   * loading the actual script and not getting warnings.
   */
  skipValidation?: boolean
}
```

## Return

See the [**Understanding proxied functions**](https://scripts.nuxt.com/docs/v0/guides/key-concepts) and [**$script**](https://unhead.unjs.io/usage/composables/use-script#argument-use-script-options) documentation for more information on the return.

[Edit this page](https://github.com/nuxt/scripts/edit/0.x/docs/content/3.api/1.use-script.md)

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

[**Facade Components** Facade Components are fake UI elements that get replaced once a third-party script loads.](https://scripts.nuxt.com/docs/v0/guides/facade-components) [**useScriptTriggerConsent** API documentation for the useScriptTriggerConsent function.](https://scripts.nuxt.com/docs/v0/api/use-script-trigger-consent)

**On this page **

- [Signature](#signature)
- [Arguments](#arguments)
- [Return](#return)

```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/v0/api/use-script#webpage","@type":"WebPage","description":"API documentation for the useScript function.","name":"useScript","url":"https://scripts.nuxt.com/docs/v0/api/use-script","breadcrumb":{"@id":"https://scripts.nuxt.com/docs/v0/api/use-script#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/docs/v0/api/use-script"]}],"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/v0/api/use-script#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":"V0","item":"https://scripts.nuxt.com/docs/v0","position":3},{"@type":"ListItem","name":"API","item":"https://scripts.nuxt.com/docs/v0/api","position":4},{"@type":"ListItem","name":"useScript","item":"https://scripts.nuxt.com/docs/v0/api/use-script","position":5}]},{"@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.
