npm

react-adsense-ad

3.4.0 • Public • Published

react-adsense-ad

react-adsense-ad is a React-component for Google AdSense advertisement.

Build Status npm npm

1. Install

npm install --save react-adsense-ad

Before use Google AdSense, you should add the script at the end of HTML.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

2. Usage

import React from 'react';
import AdSense from 'react-adsense-ad';
 
// ads with no set-up
<AdSense.Google
  client='Your Publisher Id'
  slot='Ad slot Id'
/>
 
// ads with custom format
<AdSense.Google
  client='Your Publisher Id'
  slot='Ad slot Id'
  style={{ width: 500, height: 300, float: 'left' }}
  format=''
/>
 
// responsive and native ads
<AdSense.Google
  client='Your Publisher Id'
  slot='Ad slot Id'
  style={{ display: 'block' }}
  layout='in-article'
  format='fluid'
/>
 
// auto full width responsive ads
<AdSense.Google
  client='Your Publisher Id'
  slot='Ad slot Id'
  style={{ display: 'block' }}
  format='auto'
  responsive='true'
/>

3. Props

  • Required props:
    • client
    • slot
  • Optional props:
    • className:
    • style:
    • layout:
    • format:
    • responsive:

LICENSE

MIT@aj-anuragjain.

Package Sidebar

Install

npm i react-adsense-ad

Weekly Downloads

1

Version

3.4.0

License

MIT

Unpacked Size

8.86 kB

Total Files

10

Last publish

Collaborators

  • anuragjain11