> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackfront.digital/llms.txt
> Use this file to discover all available pages before exploring further.

# Social Proof

# Social Proof

The SDK provides real-time social proof signals (e.g. "10 people are viewing this right now", "5 bought in the last hour") and product view tracking.

## Usage

```tsx theme={null}
import { useSocialProof } from 'react-native-stackfront-sdk';

function ProductSocialProof({ productId }: { productId: string }) {
  const { signals, loading, trackView } = useSocialProof(productId);

  useEffect(() => {
    trackView(); // track that the current user viewed this product
  }, [trackView]);

  if (loading || !signals) return null;

  return (
    <View>
      {signals.currentViewers > 0 && (
        <Text>{signals.currentViewers} people viewing now</Text>
      )}
      {signals.recentPurchases > 0 && (
        <Text>{signals.recentPurchases} bought in the last hour</Text>
      )}
    </View>
  );
}
```

## Hook API

```ts theme={null}
function useSocialProof(productId: string): {
  signals: SocialProofSignalsResponse | null;
  loading: boolean;
  error: Error | null;
  refetch: () => Promise<void>;
  trackView: () => Promise<void>;
}
```

## Service API

```ts theme={null}
const { socialProof } = useStackfront();

await socialProof.trackProductView({ productId, oneSignalPlayerId });
await socialProof.getSignals(productId);
```
