npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@revinel/sdk

v0.9.0

Published

Universal headless Revinel SDK for fetching and tracking publisher ads.

Readme

@revinel/sdk

Universal headless SDK for fetching and tracking Revinel publisher ads. Zero dependencies; runs in any JS runtime with fetch (browser, Node, edge, workers).

Install

npm install @revinel/sdk

Usage

import { createRevinelClient } from "@revinel/sdk"

const revinel = createRevinelClient({
  workspaceId: "your-workspace-id",
  // apiUrl is optional; it defaults to the Revinel production API. Only set it
  // to point at a local/staging API in development.
})

// Fetch the single ad currently serving for a placement.
// `weight` is a range filter: { gte, gt, lte, lt } — target a band, e.g.
// { gte: 2.5 } for premium, { lt: 2.5 } for regular cards.
const ad = await revinel.getAd({ weight: { gte: 2.5 } })

// Fetch several ads for a grid (rotation-aware; pass excludeIds to dedupe).
const ads = await revinel.getAds({ count: 5, excludeIds: ad ? [ad.id] : [] })

// Record events.
if (ad) {
  await revinel.recordImpression(ad.id)
  await revinel.recordClick(ad.id)
}

getAd resolves to RevinelAd | null; getAds to RevinelAd[] (empty when nothing is eligible; the SDK never throws on "no ads"). ad.faviconUrl is string | null.

Multiple slots on one page? Use a single getAds({ count: n }), not n × getAd(). Every getAd() sends the same request, so the shared edge cache hands back the same ad to each call, so you'd render duplicates and record duplicate impressions. One getAds({ count }) returns n distinct ads in one round trip; pass excludeIds when you fetch further ads separately to keep dedupe across calls.

Fetch on the server. Ad fetching belongs in your server/edge code (RSC, loader, route handler) so the ad is server-rendered, with no layout shift and no client waterfall. Reach for @revinel/react's useAd only in client-only apps.

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, visible in the Revinel dashboard). Register your creative shape once and every call is typed, with no per-call generic and no cast:

// revinel.d.ts (or anywhere in your app)
declare module "@revinel/sdk" {
  interface RevinelMetaRegistry {
    tagline?: string
    description?: string
    bannerImage?: string
    ctaLabel?: string
  }
}
const ad = await revinel.getAd({ weight: { gte: 2.5 } })
ad?.meta.bannerImage // string | undefined, fully typed

The slug is immutable, so renaming a field's display label never breaks your code. For a one-off shape (e.g. a multi-workspace app) you can still pass a generic: revinel.getAd<{ bannerImage?: string }>().

Next.js / caching

Ad fetches default to next: { revalidate: 60 }, so Next.js App Router pages that call getAd/getAds stay statically renderable while the ad still refreshes every minute (an explicit no-store would force the route dynamic and 500 statically-generated pages at runtime). 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):

const ad = await revinel.getAd({ request: { cache: "no-store" } })

Any explicit cache or next.revalidate replaces the default entirely.

Timeouts

Requests abort after 10 seconds by default (via AbortSignal.timeout), rejecting with a TimeoutError DOMException so a hung connection never stalls your renderer. Tune or disable it per client:

const revinel = createRevinelClient({ workspaceId: "…", timeoutMs: 5_000 }) // `false` disables

Errors

Non-2xx responses throw RevinelApiError ({ status, body }). The body is the Revinel API error envelope:

{ "defined": false, "code": "NOT_FOUND", "status": 404, "message": "Workspace not found." }

Input-validation failures use HTTP 422 with code: "INPUT_VALIDATION_FAILED" and a data.fieldErrors / data.formErrors map.

API reference

Full reference and guides: revinel.com/docs. The OpenAPI spec is served at /v1/openapi.json on the Revinel API. For React bindings see @revinel/react.