Published on

How to integrate EZOIC with React and NextJS

This is a simple guide on how to implement Ezoic monetization on your NextJS app. This guide covers only the technical aspect of the ads implementation. You have to get approved by Ezoic to show ads on your app.

Table of Contents

Inserting Ezoic standalone Javascript code

First you must copy the below code and place in _app.js file.


Inserting Ezoic placeholders

The next step is defining placeholders to show ads on your app. Ezoic uses this places to push different types of ads.

You can generate placeholders from Ezoic dashboard.


Now place the generated ad codes where you want to appear in the web app.

<div id="ezoic-pub-ad-placeholder-101"> </div>
<div id="ezoic-pub-ad-placeholder-102"> </div>

Enabling Ezoic ads

Now you can use useEffect hook to push ads to the app when an page load occurs.

useEffect(() => {
    try {
      let ezoic = ezstandalone;
      ezoic.define(101, 102);
      if (!ezoic.enabled) {
    } catch (ex) {
      // console.log("error: ", ex);
  }, []);
  • ezstandalone.define() - Defines the ad placeholders. Pass all the ad placeholder ids as parameters.
  • ezstandalone.enable() - Enables the placeholders defined.
  • ezstandalone.display() - Displays the ads in placeholders.
  • ezstandalone.refresh() - Triggers when internal navigation occurs.