0.0.1 • Published 2 years ago

@adnuntius/react-hooks v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Adnuntius React hook library

This package will help you to use Adnuntius adserver more easily in React version 16.8 or above. If you are using older versions of react you can try our other library for React that's not using hooks (currently worked on).

Installation:

npm install @adnuntius/react-hooks

Getting started

To get started using this library you will first have to create a component that will show the ads. Then make sure to run the useAdnuntius function before any conditional statments in your component.

TLDR; Example:

import './App.css';
import AdHolder, { useAdnuntius } from '@adnuntius/react-hooks';

function App() {
  useAdnuntius();
    .adUnits([
      { auId: '0000000000abc123'},
      { auId: '0000000000def456'},
    ])
    .request();

  return (
    <div className='App'>
        <AdHolder auId='0000000000abc123' />
        <AdHolder auId='0000000000def456' />
    </div>
  );
}

export default App;

The package comes with the following exports:

nameDescription
defaultExports a component by default.
useAdnuntiusMain function.

Parameters default component

One of these parameters is

nameTypeDescription
auIdstringAdunit Identifier, same id as below.
idstringIdentifier of div that gets generated.
classNamestringA class to be used as target Class, see below.

These are the functions you can use on useAdnuntius:

nameDescriptionChainable
defineAdUnitAdds one ad unit to the request chain.yes
adUnitsadds multiple ad units to the request chain.yes
userIdSets a user id to pass with the request.yes
onNoMatchedAdsPass a function to run when response is empty.ye
refreshRefresh the ad request.no
requestSends an ad request to the adserver.no