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

@gravity-ai/react-native

v0.1.0

Published

React Native components for rendering Gravity AI advertisements

Readme

@gravity-ai/react-native

React Native rendering for Gravity server-driven PSP-1 ads.

npm i @gravity-ai/react-native react react-native

react (>=18.2) and react-native (>=0.76) are peer dependencies and are never bundled. The package has no DOM or react-dom dependency.

import { GravityAd, GravityThemeProvider } from '@gravity-ai/react-native';

<GravityThemeProvider>
  <GravityAd ad={ad} onClickTracked={() => analytics.track('ad_click')} />
</GravityThemeProvider>

RN renders the portable PSP-1 profile, not the web/CSS profile. When requesting ads, send supportsSpec: true and specCapabilities: 'psp1' so the API returns specs this package can paint. The exported GRAVITY_RN_SPEC_OPTIONS object can be spread into either API request shape:

import { GRAVITY_RN_SPEC_OPTIONS } from '@gravity-ai/react-native';

const ads = await client.getAd({
  ...params,
  ...GRAVITY_RN_SPEC_OPTIONS,
});

const result = await gravityAds(req, messages, placements, {
  ...GRAVITY_RN_SPEC_OPTIONS,
});

GravityAd uses a valid server renderer_spec unless variant pins a host variant, then falls back to a small native card. The spec must be structurally valid, PSP-1 conformant, and produce content for the supplied ad; otherwise the built-in card is used. The whole card is tappable; nested spec links retain their own destinations. A native impression fires once when at least 50% of the ad's measured window area is visible, using fetch(impUrl). Measurement is retried periodically while the ad is armed, so ads mounted below the fold in a ScrollView can still fire when they become visible. It starts at 500ms, backs off to a maximum 1s cadence during the first 30 seconds off-screen, then uses a 5s low-frequency floor. It resets to 500ms whenever layout or an explicit visibility measurement signals that the surface may have moved. In a plain ScrollView, wire the returned measureVisibility callback to onScroll. Polling pauses while the app is backgrounded and resumes at the responsive cadence when the app returns to the foreground. Polling stops after the impression fires, when the ad changes, and when the component unmounts. For virtualized lists, pass isViewable from FlatList or SectionList's onViewableItemsChanged callback as the host-authoritative visibility signal; it fires immediately and disables polling for that render. useAdTracking also returns an imperative measureVisibility callback for publishers who drive visibility from their own onScroll handler. Tracking failures are swallowed.

GravityThemeProvider follows the device color scheme by default. Pass theme={{ primary: '#...' }} to override semantic tokens. $token, $token/45, hsl(var(--token)), and var(--radius) styles are understood. nowrap uses one line with tail ellipsis. maxLines remains accepted for PSP-1 compatibility but is intentionally not applied: ad copy is never client-truncated unless the spec explicitly requests nowrap.

The prop names match @gravity-ai/react where they have RN meaning. Web-only className and openInNewTab are intentionally omitted; RN navigation uses Linking.openURL.