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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@admesh/react-sdk

v1.0.2

Published

AdMesh React SDK for zero-code recommendation integration with automatic tracking

Readme

AdMesh React SDK

Zero-code React SDK for AdMesh recommendations with automatic tracking, viewability detection, and MRC compliance.

Features

  • Zero-Code Integration - Drop-in React components
  • Automatic Tracking - Exposure, click, and conversion tracking
  • MRC Compliance - Viewability detection using Intersection Observer
  • Multiple Layouts - Product card, ecommerce, and citation layouts
  • Dark Mode - Automatic dark mode support
  • Responsive - Mobile-friendly design
  • TypeScript - Full TypeScript support
  • Tree-Shakeable - Optimized bundle size

Installation

npm install @admesh/react-sdk
# or
yarn add @admesh/react-sdk
# or
pnpm add @admesh/react-sdk

Quick Start

1. Wrap Your App with Provider

import { AdMeshProvider } from '@admesh/react-sdk';

function App() {
  return (
    <AdMeshProvider
      config={{
        apiKey: 'admesh_prod_your_api_key',
        apiBaseUrl: 'https://api.admesh.com',
        debug: true
      }}
    >
      <YourApp />
    </AdMeshProvider>
  );
}

2. Use the Hook to Fetch Recommendations

import { useRecommendations, RecommendationGrid } from '@admesh/react-sdk';

function RecommendationsPage() {
  const { recommendations, loading, error } = useRecommendations({
    query: 'laptop under $1000',
    limit: 5
  });

  return (
    <RecommendationGrid
      recommendations={recommendations}
      loading={loading}
      error={error}
    />
  );
}

Usage Examples

Basic Grid

import { useRecommendations, RecommendationGrid } from '@admesh/react-sdk';

export function BasicExample() {
  const { recommendations, loading, error } = useRecommendations({
    query: 'best laptops',
    limit: 6
  });

  return (
    <RecommendationGrid
      recommendations={recommendations}
      loading={loading}
      error={error}
      columns={3}
    />
  );
}

With Callbacks

export function AdvancedExample() {
  const { recommendations, loading, error } = useRecommendations({
    query: 'best laptops'
  });

  return (
    <RecommendationGrid
      recommendations={recommendations}
      loading={loading}
      error={error}
      onRecommendationVisible={(rec, metrics) => {
        console.log(`${rec.title} is visible:`, metrics);
      }}
      onRecommendationClick={(rec) => {
        console.log(`Clicked: ${rec.title}`);
      }}
    />
  );
}

Custom Viewability Tracking

import { useViewabilityTracker } from '@admesh/react-sdk';

export function CustomTracking() {
  const { ref, isVisible, metrics } = useViewabilityTracker({
    threshold: 75,
    duration: 2000,
    onVisible: (metrics) => {
      console.log('Element is visible:', metrics);
    }
  });

  return (
    <div ref={ref}>
      {isVisible && <p>This element is visible!</p>}
      {metrics && <p>Viewability: {metrics.score}%</p>}
    </div>
  );
}

API Reference

AdMeshProvider

Wraps your app and provides AdMesh context.

<AdMeshProvider
  config={{
    apiKey: string;              // Required: Your API key
    apiBaseUrl?: string;         // Optional: API base URL
    viewabilityConfig?: {        // Optional: Viewability settings
      threshold: number;         // 0-100, default: 50
      duration: number;          // milliseconds, default: 1000
    };
    debug?: boolean;             // Optional: Enable debug logging
  }}
>
  {children}
</AdMeshProvider>

useRecommendations

Hook to fetch recommendations.

const { recommendations, loading, error, refetch } = useRecommendations({
  query: string;           // Required: Search query
  limit?: number;          // Optional: Max results (default: 5)
  category?: string;       // Optional: Product category
  maxPrice?: number;       // Optional: Max price in cents
  minRating?: number;      // Optional: Min rating (0-5)
  enabled?: boolean;       // Optional: Enable/disable fetching
});

useViewabilityTracker

Hook for MRC-compliant viewability tracking.

const { ref, isVisible, metrics } = useViewabilityTracker({
  threshold?: number;      // 0-100, default from config
  duration?: number;       // milliseconds, default from config
  onVisible?: (metrics) => void;  // Callback when visible
});

RecommendationCard

Component for a single recommendation.

<RecommendationCard
  recommendation={rec}
  onVisible={(metrics) => {}}
  onClick={() => {}}
  className="custom-class"
/>

RecommendationGrid

Component for a grid of recommendations.

<RecommendationGrid
  recommendations={recs}
  loading={false}
  error={null}
  onRecommendationVisible={(rec, metrics) => {}}
  onRecommendationClick={(rec) => {}}
  columns={3}
  gap="16px"
  className="custom-class"
/>

Styling

The SDK includes default styles. Customize with CSS:

.admesh-recommendation-card {
  border-radius: 8px;
}

.admesh-cta-button {
  background: #007bff;
}

Browser Support

  • Chrome 51+
  • Firefox 55+
  • Safari 12.1+
  • Edge 15+
  • Mobile browsers (iOS Safari 12.2+, Chrome Mobile)

Performance

  • Bundle size: ~15 KB (minified + gzipped)
  • SDK initialization: <100ms
  • Recommendation fetch: 200-500ms
  • Display rendering: <50ms

Troubleshooting

SDK Not Loading

// Check if provider is wrapping your component
<AdMeshProvider config={...}>
  <YourComponent />
</AdMeshProvider>

No Recommendations

// Enable debug mode
<AdMeshProvider
  config={{
    apiKey: 'admesh_prod_xxx',
    debug: true  // Check console for errors
  }}
>

Tracking Not Working

  • Verify API key is valid
  • Check network tab for API calls
  • Ensure recommendations are visible
  • Check rate limits

Support

  • Documentation: https://docs.admesh.com
  • Issues: https://github.com/admesh/react-sdk/issues
  • Email: [email protected]

License

MIT

Contributing

Contributions welcome! Please read our contributing guidelines.

Changelog

1.0.0

  • Initial release
  • React 16.8+ support
  • TypeScript support
  • MRC viewability tracking
  • Automatic exposure/click tracking