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

@action-x/ad-sdk

v0.1.12

Published

Zero-dependency ad SDK for ActionX

Readme

@action-x/ad-sdk

An ad SDK for AI conversation experiences, with zero framework dependencies. Works with Vanilla JS, Vue, React, Angular, Svelte, and more.


Installation

npm install @action-x/ad-sdk
# or
yarn add @action-x/ad-sdk
# or
pnpm add @action-x/ad-sdk

Import styles (required):

import '@action-x/ad-sdk/style.css';

AdCard Component

Below are AdCard wrapper examples for different frameworks. The component takes query and response from the AI conversation, then automatically requests and renders an ad card after the response is complete.

Vue 3

<!-- AdCard.vue -->
<template>
  <div ref="adEl" />
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { AdManager } from '@action-x/ad-sdk';
import '@action-x/ad-sdk/style.css';

const props = defineProps(['query', 'response']);
const adEl = ref(null);
let manager;

onMounted(async () => {
  manager = new AdManager({
    apiBaseUrl: 'https://your-api.example.com/api/v1',
    apiKey: 'ak_your_api_key',
  });

  await manager.requestAds({ query: props.query, response: props.response });

  manager.render(adEl.value);
});

onUnmounted(() => manager?.destroy());
</script>

React

// components/AdCard.tsx
import { useEffect, useRef } from 'react';
import { AdManager } from '@action-x/ad-sdk';
import '@action-x/ad-sdk/style.css';

interface Props {
  query: string;
  response: string;
}

export function AdCard({ query, response }: Props) {
  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const manager = new AdManager({
      apiBaseUrl: 'https://your-api.example.com/api/v1',
      apiKey: 'ak_your_api_key',
    });

    manager
      .requestAds({ query, response })
      .then(() => {
        if (containerRef.current) {
          manager.render(containerRef.current);
        }
      });

    return () => manager.destroy();
  }, [query, response]);

  return <div ref={containerRef} />;
}

Vanilla JavaScript

import { AdManager } from '@action-x/ad-sdk';
import '@action-x/ad-sdk/style.css';

const manager = new AdManager({
  apiBaseUrl: 'https://your-api.example.com/api/v1',
  apiKey: 'ak_your_api_key',
});

// Request and render ads after the AI response is complete
await manager.requestAds({
  query: 'Recommend a Bluetooth headset',
  response: 'Here are several popular Bluetooth headset options...',
});

manager.render(document.getElementById('ad-card'));

CDN (No Build Tool)

<link rel="stylesheet" href="https://unpkg.com/@action-x/ad-sdk/style.css" />
<script src="https://unpkg.com/@action-x/ad-sdk/dist/index.umd.js"></script>

<div id="ad-card"></div>

<script>
  const { AdManager } = ActionXAdSDK;

  const manager = new AdManager({
    apiBaseUrl: 'https://your-api.example.com/api/v1',
    apiKey: 'ak_your_api_key',
  });

  manager
    .requestAds({ query: 'User question', response: 'AI response' })
    .then(() => {
      manager.render(document.getElementById('ad-card'));
    });
</script>

Usage Example

Render an Ad Card After AI Response Completes

Using React as an example, render AdCard after streaming output finishes:

import { useState } from 'react';
import { AdCard } from './components/AdCard';

export function ChatMessage() {
  const [query, setQuery] = useState('');
  const [response, setResponse] = useState('');
  const [isStreaming, setIsStreaming] = useState(false);

  async function handleSend(userQuery: string) {
    setQuery(userQuery);
    setIsStreaming(true);
    setResponse('');

    // Receive AI response as a stream
    const stream = await fetchAIResponse(userQuery);
    let fullResponse = '';
    for await (const chunk of stream) {
      fullResponse += chunk;
      setResponse(fullResponse);
    }

    setIsStreaming(false);
    // After response completes, AdCard will request and render automatically
  }

  return (
    <div>
      <div className="response">{response}</div>

      {/* Show ad card after response streaming ends */}
      {!isStreaming && response && (
        <AdCard query={query} response={response} />
      )}
    </div>
  );
}

Configuration

new AdManager(config)

| Parameter | Type | Required | Description | |------|------|------|------| | apiBaseUrl | string | Yes | API base URL, e.g. https://your-api.example.com/api/v1 | | apiKey | string | Yes | API authentication key | | cardOption | CardOption | No | Card options with sensible defaults |

Card Options cardOption

| Parameter | Type | Default | Description | |------|------|--------|------| | variant | 'horizontal' \| 'vertical' \| 'compact' | 'horizontal' | Layout style | | count | number | 1 | Number of ads to request |

Customization example:

new AdManager({
  apiBaseUrl: '...',
  apiKey: '...',
  cardOption: {
    variant: 'vertical',
    count: 2,
  },
});

requestAds(context)

| Parameter | Type | Required | Description | |------|------|------|------| | query | string | Yes | User question | | response | string | Yes | AI response text |

render(container, options?)

| Parameter | Type | Description | |------|------|------| | container | HTMLElement | Mount container | | options.onClick | (ad) => void | Click callback | | options.onImpression | (ad) => void | Impression callback |


Event Listeners

manager.on('adsUpdated',   (slots) => { /* ad data ready */ });
manager.on('adsLoading',   ()      => { /* requesting */ });
manager.on('adsError',     (err)   => { /* request failed */ });
manager.on('adClicked',    (adId, slotId) => { });
manager.on('adImpression', (adId, slotId) => { });

Version: 0.1.0 | License: MIT