Tutorials

How to configure providers

Here we modify the image provider from the previous example so that it accepts width and height parameters. Then we use our new parameters by setting the params container option.

Parameters are sent by the container in the load and unload requests to the connected provider. An example of a common use case for parameters is when supplying a placement id to a provider that loads ads from an ad server.

Setup
adk.container.addProvider('my-provider', {
    load: ({ elem, params }) => {
        const { width, height } = params
        elem.innerHTML = `<img src="https://picsum.photos/${width}/${height}">`
    },
})

adk.config()
    .addContainer('my-container', adk.container.config()
        .provider('my-provider')
        .params({
            width: 300,
            height: 600,
        }))
    .apply()
    .init(publisherId)
Result