-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting & FAQ
Soufiane Amediaz edited this page Aug 30, 2026
·
1 revision
Frequently asked questions, common pitfalls, and resolution recipes when integrating adinject-react.
-
Root Cause: You called
<AdSenseSlot />or another client component directly inside an async Server Component page without importing it properly or missing client boundaries. -
Solution: Ensure your component files use
"use client"at the top if they wrap hooks or local state:
// src/components/blog-ad.tsx
"use client";
import { AdSenseSlot } from "adinject-react";
export function BlogSidebarAd() {
return <AdSenseSlot slot="9876543210" format="rectangle" />;
}Check the following checklist:
-
Consent State: Did user grant consent? If
ConsentProvideris in"unknown"or"denied"state, ad network tags are blocked by design. -
Ad Blockers: Verify if a browser ad blocker (uBlock Origin, Brave Shields) is active. With an ad blocker active, the component will safely render your configured
<AdFallback />. -
Publisher ID & Slot: Double check that
ca-pub-XXXXXXXXXXXXXXXXand slot ID match your verified Google AdSense / GAM dashboard. -
AdSense Account Status: New AdSense sites must be reviewed and approved by Google before live creatives display. In development, use
testMode={true}to verify layout stability without requiring an active AdSense approval.
⚠️ Issue: Warning in browser console: [AdInject CLS Guard] Ad slot #... rendered at ...px but reserved ...px
-
Root Cause: In development mode,
adinject-reactchecks the actual creative height against the reserved min-height bounding box. If the ad network serves a creative of a different size (e.g. 300x600 inside a 300x250 container), layout shift could occur. - Solution: Specify custom dimensions on the slot to match the creative served:
<AdSenseSlot
slot="9876543210"
format="rectangle"
dimensions={{ minHeight: 280, aspectRatio: "336/280" }}
/>-
Explanation:
adinject-reactuses an internal script deduplication registry (loadScriptOnce) and idempotent cache (idempotencyKey).AdSenseScriptinapp/layout.tsxguarantees that the Google script is attached todocument.headexactly once per browser session.
-
Avoid Accidental Clicks: Do not place ad slots directly above or below primary navigation buttons, search inputs, or pagination controls. Maintain at least
16pxto24pxmargin. -
Ad Density: Ensure advertising does not exceed 30% of total visible page content.
<InArticleAds />andinjectFeedAdslet you control intervals (interval={3}orinterval={4}) to maintain compliant density. -
Accessibility: Every ad slot rendered by
adinject-reactcarriesrole="complementary"andaria-label="Advertisement"to announce sponsored content to screen readers. -
FTC Disclosures: Always place
<AffiliateDisclosure />near the top of the article before any affiliate links or product cards appear.
adinject-react is maintained by LinuxCTRL. Distributed under the MIT License.
GitHub • npm • Live Showcase • Report Issue