🚀 Integrate Google Double Click for Publishers in Next.js with ease
npm i @blackbox-vision/next-google-dfp
yarn add @blackbox-vision/next-google-dfp
export const ads = [
{
slotId: "/6355419/Travel/Europe/France/Paris",
sizeMappings: [300, 250],
divId: "banner-ad",
},
];
import { AdsProvider } from "@blackbox-vision/next-google-dfp";
import { ads } from "../constants/ads";
function MyApp({ Component, pageProps }) {
return (
<AdsProvider ads={ads} enableLazyload>
<Component {...pageProps} />
</AdsProvider>
);
}
export default MyApp;
import { Ad } from "@blackbox-vision/next-google-dfp";
function Page() {
return <Ad id="banner-ad" width={300} height={250} />;
}
export default Page;
Responsive slots can be defined with this structure:
export const ads = [
{
slotId: "/6355419/Travel/Europe/France/Paris",
sizeMappings: [
{
breakpoint: [1024, 768],
sizes: [
[980, 90],
[980, 250],
[728, 90],
],
}, //viewport >1024px
{
breakpoint: [0, 0],
sizes: [
[320, 100],
[320, 50],
],
}, //viewport <1024px
],
divId: "banner-ad",
},
];
// TODO: add props, add support for more cases, show targeting support