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

@vtex/ads-core

v0.5.0

Published

Core JavaScript SDK for requesting and managing VTEX Ads in any JavaScript environment. This package provides the fundamental advertising functionality with maximum flexibility and control, making it perfect for non-React applications or when you need cus

Readme

@vtex/ads-core

Core JavaScript SDK for requesting and managing VTEX Ads in any JavaScript environment. This package provides the fundamental advertising functionality with maximum flexibility and control, making it perfect for non-React applications or when you need custom integration patterns.

Installation

npm install @vtex/ads-core
# or
yarn add @vtex/ads-core

Basic Usage

Getting Raw Ads

The simplest way to fetch ads is using getRawAds():

import { getRawAds } from "@vtex/ads-core";

const adRequest = {
  identity: {
    accountName: "your-account-name",
    publisherId: "your-publisher-id",
    userId: "user-123",
    sessionId: "session-456",
    channel: "web", // optional: 'web' | 'mobile'
  },
  search: {
    term: "smartphone", // optional search term
    selectedFacets: [
      // optional filters
      { key: "brand", value: "Acme" },
      { key: "category", value: "Tools" },
    ],
  },
  placements: {
    search_top_product: {
      quantity: 3,
      types: ["product"],
    },
  },
};

try {
  const rawAds = await getRawAds(adRequest);
  console.log("Raw ads:", rawAds.sponsoredProducts);
} catch (error) {
  console.error("Failed to fetch ads:", error);
}

Getting Hydrated Ads

For a quick setup using VTEX's Intelligent Search, use the built-in hydration strategy:

import { getHydratedAdsByIS } from "@vtex/ads-core";

const hydratedAds = await getHydratedAdsByIS(adRequest);
console.log("Hydrated ads:", hydratedAds.sponsoredProducts);

Custom hydration

For ads enriched with product details, use getHydratedAds() with custom fetcher and matcher functions:

import { getHydratedAds } from "@vtex/ads-core";

const customFetcher = async (offers, identity) => {
  // Your custom logic to fetch product details
  // Return array of products matching the offers
};

const customMatcher = (product, offer) => {
  // Your custom logic to match products with offers
  // Return true if product matches the offer
};

const hydratedAds = await getHydratedAds(
  adRequest,
  customFetcher,
  customMatcher,
);

console.log("Hydrated ads:", hydratedAds.sponsoredProducts);

Key Concepts

  • Raw Ads: Basic ad data from the Ad Server without product enrichment
  • Hydrated Ads: Ads enriched with detailed product information
  • Fetcher: Function that retrieves product details for ad offers
  • Matcher: Function that determines if a product matches an ad offer
  • Placements: Named locations where ads will be displayed