react-freemium-ads
v0.0.1
Published
This package provides a freemium ads module (AdProvider, AdSlot) for route-based ad control and disabling ads for premium users.
Downloads
6
Readme
react-freemium-ads
This package provides a freemium ads module (AdProvider, AdSlot) for route-based ad control and disabling ads for premium users.
Usage Example (Freemium Ads)
import { AdProvider, AdSlot } from "npm-react-package-template";
type AppProps = {
isPremium: boolean;
pathname: string;
};
export function App({ isPremium, pathname }: AppProps) {
return (
<AdProvider
plan={isPremium ? "premium" : "free"}
currentPath={pathname}
config={{
adClient: "ca-pub-xxxxxxxxxxxxxxxx",
slots: {
banner: "1111111111",
multiplex: "2222222222",
},
allowedPaths: ["/", "/search", "/result"],
blockedPaths: [
"/checkout",
"/billing",
"/account",
"/login",
"/privacy",
"/terms",
],
}}
>
<header>
<AdSlot placement="banner" />
</header>
<main>
{/* Your search/result UI */}
<AdSlot placement="multiplex" />
</main>
</AdProvider>
);
}Notes:
premiumusers do not load the AdSense script.- Use
allowedPaths/blockedPathsto control ad visibility by route. - Use AdSense dashboard settings for Anchor/Vignette behavior.
