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

@affiliateo/react-native

v4.2.0

Published

Affiliateo SDK for React Native. mobile affiliate attribution and session tracking

Downloads

1,623

Readme

@affiliateo/react-native

Affiliateo SDK for React Native. mobile affiliate attribution and screen tracking.

Install

npm install @affiliateo/react-native

Setup

Wrap your app with AffiliateoProvider. To get a complete funnel without adding tracking calls to every screen, also pass a React Navigation navigationRef. the SDK subscribes to navigation state changes and auto-fires one screen_view per route.

import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
import { AffiliateoProvider } from '@affiliateo/react-native';

export default function App() {
  const navigationRef = useNavigationContainerRef();
  return (
    <NavigationContainer ref={navigationRef}>
      <AffiliateoProvider
        campaignId="YOUR_CAMPAIGN_ID"
        navigationRef={navigationRef}
      >
        <YourApp />
      </AffiliateoProvider>
    </NavigationContainer>
  );
}

Without navigationRef the SDK still fires an entry screen_view at launch and a final one on background, but per-screen tracking would require manual .page() calls.

Track Screens manually (optional)

If you don't use React Navigation, or want to fire a specific custom screen name, call .page() from the context:

import { useAffiliateRef } from '@affiliateo/react-native';

function PricingScreen() {
  const { page } = useAffiliateRef();
  useEffect(() => { page('Pricing'); }, []);
  return <View>...</View>;
}

Track custom goals

Screen views auto-track. For specific moments that matter to your funnel (signup_completed, trial_started, etc.), call track():

import { useEffect } from 'react';
import { useAffiliateRef } from '@affiliateo/react-native';

function SignupSuccessScreen() {
  const { track } = useAffiliateRef();
  useEffect(() => {
    track('signup_completed', { plan: 'free' });
  }, []);
  return <View>...</View>;
}

Goal names: lowercase letters, digits, underscores, hyphens, colons. Max 64 chars. Optional metadata bounded to 4KB JSON.

Identify signed-in users (cross-device stitching)

Without identify(), the same person on phone + tablet counts as two visitors and your funnel splits. Call once after sign-in:

import { useEffect } from 'react';
import { useAffiliateRef } from '@affiliateo/react-native';
import { useUser } from './your-auth';

export default function App() {
  const { identify } = useAffiliateRef();
  const user = useUser();
  useEffect(() => {
    if (user) identify(user.id);
  }, [user]);
  return <NavigationContainer>...</NavigationContainer>;
}

Idempotent. safe to fire on every app launch while a user is signed in. user_id only. The SDK does not accept, collect, or transmit email or any other PII.

Get Affiliate Ref

import { useAffiliateRef } from '@affiliateo/react-native';

function MyComponent() {
  const { refCode, isMatched, isLoading } = useAffiliateRef();
  // ...
}

Apple Native IAP (StoreKit 2)

If your iOS app uses StoreKit 2 directly (not RevenueCat), pass the SDK's appAccountToken to your purchase call. Apple stamps it onto every transaction in the chain so we can credit the affiliate on every renewal and refund.

import { useAffiliateRef } from '@affiliateo/react-native';
import { requestPurchase } from 'expo-iap'; // or react-native-iap v14+

function BuyButton() {
  const { appAccountToken } = useAffiliateRef();

  async function buy() {
    await requestPurchase({
      sku: 'pro_monthly',
      appAccountTokenIOS: appAccountToken ?? undefined,
    });
  }

  return <Button onPress={buy} title="Subscribe" />;
}

Swift StoreKit 2 (if you have a Swift purchase layer):

let token = UUID(uuidString: affiliateoAppAccountToken)
let result = try await product.purchase(
  options: token.map { [.appAccountToken($0)] } ?? []
)

Requires iOS 15+. On Android (or before identify completes, or for unmatched users), appAccountToken is null.

How It Works

  1. On first app open, the SDK sends a device fingerprint to Affiliateo
  2. Affiliateo matches it against recent affiliate link clicks using IP + device signals
  3. If matched, the SDK:
    • Auto-sets the affiliateo_ref attribute on RevenueCat (if installed)
    • Mints + registers a StoreKit 2 appAccountToken so Apple native purchases get attributed automatically
  4. Screen views are batched and sent every 30s for funnel analytics
  5. Events are persisted offline and flushed when connectivity returns