UNPKG

google-adsense

Version:

Add Google AdSense to your React project instantly. This simple component handles both auto and manual ad setup.

72 lines (71 loc) 1.79 kB
import React from "react"; declare global { interface Window { adsbygoogle?: Array<{}>; } } /** * Interface for the AdSense component props. */ interface AdSenseProps { /** * Your Google AdSense Publisher ID. Required. * Example: "ca-pub-1234567890123456" */ client: string; /** * The ad slot ID. Required for manual ad placement. * Leave undefined for Auto Ads. * Example: "1234567890" */ slot?: string; /** * The ad format. Defaults to "auto". * Use this for manual ad placements. * Valid values depend on ad unit setup in AdSense. * Example: "horizontal", "vertical", "square" */ format?: string; /** * Class name for the ad element (<ins></ins> tags). */ className?: string; /** * Additional class names for the ad container element. */ containerClass?: string; /** * Inline styles for the ad container element. */ style?: React.CSSProperties; /** * Ad layout. For responsive ads. Consult AdSense docs. */ layout?: string; /** * Ad layout key. For responsive ads. Consult AdSense docs. */ layoutKey?: string; /** * Ad layout density. For responsive ads. Consult AdSense docs. */ layoutDensity?: string; /** * Full width responsive ads. Defaults to false. */ fullWidthResponsive?: boolean; /** * Width of the ad container. Defaults to "100%". */ width?: string; /** * Height of the ad container. Defaults to "auto". */ height?: string; } /** * A React component for displaying Google AdSense ads. * Supports both manual ad placements and Auto Ads. */ declare const AdSense: React.FC<AdSenseProps>; export default AdSense;