---
title: "Carbon Ads Component for Nuxt · Nuxt Scripts"
description: "Place Carbon Ads in a Nuxt page with the headless ScriptCarbonAds component. It loads the Carbon Ads embed script for you."
canonical_url: "https://scripts.nuxt.com/scripts/carbon-ads"
meta:
  "og:description": "Place Carbon Ads in a Nuxt page with the headless ScriptCarbonAds component. It loads the Carbon Ads embed script for you."
  "og:image": "https://scripts.nuxt.com/_og/s/o_6733b49d459c861b.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Carbon Ads Component for Nuxt · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_6733b49d459c861b.png"
---

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

**Scripts**

# **Carbon Ads**

[Copy for LLMs](https://scripts.nuxt.com/scripts/carbon-ads.md)

[**Carbon Ads**](https://www.carbonads.net/) serves ads through a standard embed script.

Use the headless [`**<ScriptCarbonAds>**`](https://scripts.nuxt.com/scripts/carbon-ads) component to place one of its ads in a Nuxt page.

**Carbon Ads**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/components/ScriptCarbonAds.vue)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load Carbon Ads globally. Alternatively you can use the **false** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      carbonAds: {
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

This config automatically enables **first-party mode ** (proxy). See below to customise.

## First-Party Mode: Privacy Focused Proxy

No extra config needed. Runtime requests are reverse-proxied through your server instead of going directly to Carbon Ads. User IPs are anonymised and requests work with ad blockers. [**Learn more. **](https://scripts.nuxt.com/docs/guides/first-party)

**Mode**

~~Bundle ~~ Proxy

**Privacy**

User IP addresses are anonymised. Other request data passes through.

```
export default defineNuxtConfig({
  scripts: {
    // ✅ First-party mode: proxied
    registry: {
      carbonAds: {
        trigger: 'onNuxtReady',
      },
    },
  },
})
```

## [`**<ScriptCarbonAds>**`](https://scripts.nuxt.com/scripts/carbon-ads)

Unlike other Nuxt Scripts components, `**<ScriptCarbonAds>**` bypasses [`**useScript()**`](https://scripts.nuxt.com/docs/api/use-script) and inserts the Carbon script into its own `**div**`.

It loads when mounted. Pass an [**element event trigger**](https://scripts.nuxt.com/docs/guides/script-triggers#element-event-triggers) if the ad should wait for a specific interaction.

Carbon's [**placement policy**](https://www.carbonads.net/placement-policy) requires the ad code to load only once per page and forbids modifying or self-hosting the script. Render one component for the active page. The component requests Carbon's CDN script directly, but it does not enforce the one-component limit.

```vue
<template>
  <ScriptCarbonAds
    serve="..."
    placement="..."
    format="..."
  />
</template>
```

### Handling ad blockers

Use the `**error**` slot when Carbon Ads is blocked:

```vue
<template>
  <ScriptCarbonAds
    serve="..."
    placement="..."
    format="..."
  >
    <template #error>
      <!-- Fallback ad -->
      Please support us by disabling your ad blocker.
    </template>
  </ScriptCarbonAds>
</template>
```

### Adding UI

The component has no inherited styles. This example uses the styles from [**nuxt.com**](http://nuxt.com):

```vue
<template>
  <ScriptCarbonAds
    class="Carbon border border-gray-200 dark:border-gray-800 rounded-lg bg-white dark:bg-white/5"
    serve="..."
    placement="..."
    format="..."
  />
</template>

<style lang="postcss">
/* Credits to nuxt.com */
.dark .Carbon {
  min-height: 220px;
  .carbon-text {
    @apply text-gray-400;

    &:hover {
      @apply text-gray-200;
    }
  }
}

.light .Carbon {
  .carbon-text {
    @apply text-gray-600;

    &:hover {
      @apply text-gray-800;
    }
  }
}

.Carbon {
  @apply p-3 flex flex-col max-w-full;

  @screen sm {
    @apply max-w-xs;
  }

  @screen lg {
    @apply mt-0;
  }

  #carbonads span {
    @apply flex flex-col justify-between;

    .carbon-wrap {
      @apply flex flex-col;

      flex: 1;

      @media (min-width: 320px) {
        @apply flex-row;
      }

      @screen lg {
        @apply flex-col;
      }

      .carbon-img {
        @apply flex items-start justify-center mb-4;

        @media (min-width: 320px) {
          @apply mb-0;
        }

        @screen lg {
          @apply mb-4;
        }
      }

      .carbon-text {
        @apply flex-1 text-sm w-full m-0 text-left block;

        &:hover {
          @apply no-underline;
        }

        @media (min-width: 320px) {
          @apply ml-4;
        }

        @screen lg {
          @apply ml-0;
        }
      }
    }
  }

  img {
    @apply w-full;
  }

  & .carbon-poweredby {
    @apply ml-2 text-xs text-right text-gray-400 block pt-2;

    &:hover {
      @apply no-underline text-gray-500;
    }
  }
}
</style>
```

### Component API

See the [**Facade Component API**](https://scripts.nuxt.com/docs/guides/facade-components#facade-components-api) for full props, events, and slots.

The component's `**ready**` event receives the injected `**HTMLScriptElement**`.

`**serve**``string`** required **

`**placement**``string`** required **

`**format**``string`** required **

`**trigger**``ElementScriptTrigger`

Defines the trigger event to load the script.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/carbon-ads.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/carbon-ads.md)

[**Calendly** Embed Calendly bookings in your Nuxt app with inline, popup, and badge widgets.](https://scripts.nuxt.com/scripts/calendly) [**Clarity** Load Microsoft Clarity and manage its session-recording consent state.](https://scripts.nuxt.com/scripts/clarity)

```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/scripts/carbon-ads#webpage","@type":"WebPage","description":"Place Carbon Ads in a Nuxt page with the headless ScriptCarbonAds component. It loads the Carbon Ads embed script for you.","name":"Carbon Ads Component for Nuxt","url":"https://scripts.nuxt.com/scripts/carbon-ads","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/carbon-ads#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/carbon-ads"]}],"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/scripts/carbon-ads#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Carbon Ads","item":"https://scripts.nuxt.com/scripts/carbon-ads","position":3}]},{"@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.
