0.0.1 • Published 2 years ago
@adnuntius/react-hooks v0.0.1
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:
name | Description |
---|---|
default | Exports a component by default. |
useAdnuntius | Main function. |
Parameters default component
One of these parameters is
name | Type | Description |
---|---|---|
auId | string | Adunit Identifier, same id as below. |
id | string | Identifier of div that gets generated. |
className | string | A class to be used as target Class, see below. |
These are the functions you can use on useAdnuntius:
name | Description | Chainable |
---|---|---|
defineAdUnit | Adds one ad unit to the request chain. | yes |
adUnits | adds multiple ad units to the request chain. | yes |
userId | Sets a user id to pass with the request. | yes |
onNoMatchedAds | Pass a function to run when response is empty. | ye |
refresh | Refresh the ad request. | no |
request | Sends an ad request to the adserver. | no |
0.0.1
2 years ago