fetch (browser, Node, edge, workers).
Install
Usage
getAd resolves to RevinelAd | null; getAds to RevinelAd[] (empty when nothing is
eligible; the SDK never throws on “no ads”).
Typed creative (meta)
ad.meta is keyed by each custom field’s stable machine slug (set when the publisher
creates the field, e.g. bannerImage for a “Banner image” field). Pass your own interface
for typesafe access:
Next.js / caching
Ad fetches default tonext: { revalidate: 60 }, so App Router pages that call
getAd/getAds stay statically renderable while the ad still refreshes every minute.
(Revinel’s API edge-caches responses for ~5s anyway, so per-request rotation was always
approximate.) Non-Next runtimes ignore the next key: server fetches (Node/edge) stay
uncached, while browsers honor the response Cache-Control (max-age=5) and may reuse
an identical request for up to ~5s, the same window the API’s edge cache already
imposes.
Opt out for true per-request rotation (on an already-dynamic Next page, or anywhere
else):
cache or next.revalidate you pass replaces the default entirely.
Errors
Non-2xx responses throwRevinelApiError ({ status, body }). The body is the Revinel
API error envelope:
code: "INPUT_VALIDATION_FAILED" and a
data.fieldErrors / data.formErrors map.
For React bindings see @revinel/react.