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.9.1

Published

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

Downloads

1,045

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
        appId="YOUR_APP_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. The SDK auto-sets the affiliateo_visitor_id attribute on RevenueCat (if installed) so every purchase links back to this device's tracked visitor (per-buyer spend, funnels, ad ROAS). If matched, it additionally:
    • Auto-sets the affiliateo_ref attribute on RevenueCat
    • 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

Giving affiliates free access

App owners can switch complimentary access on for an individual affiliate from their Affiliateo dashboard, which grants a promotional entitlement in their own RevenueCat project.

Nothing to add to your code. As of 4.7.0 the SDK reads your RevenueCat App User ID itself, on launch and on every foreground. If react-native-purchases isn't installed, or RevenueCat hasn't configured yet, it does nothing and tries again next time.

Before 4.7.0 this needed a setRevenueCatUser() call you had to add yourself. That call still exists if you want to control the timing:

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

const { setRevenueCatUser } = useAffiliateRef();

// after Purchases.configure(...) — optional, the SDK already does this
setRevenueCatUser(await Purchases.getAppUserID());

Sending the same id repeatedly is a no-op. RevenueCat issues an anonymous placeholder until your app calls Purchases.logIn(); the SDK re-reads on foreground and the server accepts exactly one upgrade from that placeholder to the real id.

An affiliate still has to have opened your app through their own referral link at least once, since that link is what tells us which device is theirs. Until then the owner sees a disabled switch reading "hasn't opened your app yet".

Notes:

  • It's separate from identify() on purpose. Sign-in and RevenueCat setup happen at different moments, and your app may do one without the other.
  • The value is write-once per device. Sending a different ID for a device that's already bound is rejected, so a tampered client can't repoint a device at another customer.
  • No email or other PII is sent, same as identify().