---
title: Iframe Blocking
description: Block embedded content (YouTube, social widgets, maps) until users grant consent for the appropriate category.
---
<import src="../../shared/react/guides/iframe-blocking.mdx#intro" />

## Frame Component

The `<Frame>` component wraps content that requires consent. Children are only mounted when the specified category has consent. When consent is not granted, a placeholder is shown instead.

```tsx
import { Frame } from '@c15t/nextjs';

function YouTubeEmbed() {
  return (
    <Frame category="marketing">
      <iframe
        src="https://www.youtube.com/embed/dQw4w9WgXcQ"
        width="560"
        height="315"
        allowFullScreen
      />
    </Frame>
  );
}
```

<import src="../../shared/react/guides/iframe-blocking.mdx#custom-placeholder" />

<import src="../../shared/react/guides/iframe-blocking.mdx#html-approach" />

## Initializing the Iframe Blocker

The iframe blocker for HTML attributes needs to be initialized separately from the Frame component:

```tsx
import { useConsentManager } from '@c15t/nextjs';
import { useEffect } from 'react';

function IframeBlockerInit() {
  const { initializeIframeBlocker } = useConsentManager();

  useEffect(() => {
    initializeIframeBlocker();
  }, [initializeIframeBlocker]);

  return null;
}
```

<import src="../../shared/react/guides/iframe-blocking.mdx#api-reference" />
