---
title: crossOrigin
description: "Use the `crossOrigin` option to add a crossOrigin tag on the `script` tags generated by `next/script` and `next/head`."
url: "https://nextjs.org/docs/15/pages/api-reference/config/next-config-js/crossOrigin"
docs_index: /docs/15/pages/llms.txt
lastUpdated: 2025-04-15
prerequisites:
  - "Configuration: /docs/15/pages/api-reference/config"
  - "next.config.js Options: /docs/15/pages/api-reference/config/next-config-js"
---

> For an index of all documentation, see [/docs/15/pages/llms.txt](/docs/15/pages/llms.txt).

Use the `crossOrigin` option to add a [`crossOrigin` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) in all `<script>` tags generated by the  [`next/script`](/docs/pages/guides/scripts) and [`next/head`](/docs/pages/api-reference/components/head)components, and define how cross-origin requests should be handled.

```js title="next.config.js"
module.exports = {
  crossOrigin: 'anonymous',
}
```

## Options

- `'anonymous'`: Adds [`crossOrigin="anonymous"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin#anonymous) attribute.
- `'use-credentials'`: Adds [`crossOrigin="use-credentials"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin#use-credentials).

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/docs/15/pages/llms.txt](/docs/15/pages/llms.txt)