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

@clevertap/native-display-sdk

v1.0.0

Published

CleverTap Native Display SDK for React Native - server-driven native UI from JSON

Readme

CleverTap Native Display for React Native

Package: @clevertap/native-display-sdk

What this is

CleverTap lets you design UI campaigns (banners, cards, carousels, and more) on the CleverTap dashboard and send them to your app. This package draws those campaigns as real, native React Native screens - no WebViews. You design once on the dashboard; the app shows it without an app-store update.

This package is only the part that draws the campaign. The campaign itself is delivered by the main CleverTap SDK (clevertap-react-native). So you always set up CleverTap first, then add this package on top.

Works with both kinds of React Native apps: plain ("bare") React Native and Expo.

Quick facts

| Question | Answer | |---|---| | Which platforms? | iOS and Android | | Minimum versions | React Native 0.73+, React 18+, clevertap-react-native 4.5+ | | Does it add native code of its own? | No. This package is pure TypeScript. (The main CleverTap SDK does have native code.) | | Does it work with Expo? | Yes, with expo prebuild or EAS Build. Not with Expo Go. | | Where are campaigns designed? | On the CleverTap dashboard, not in code. | | Who authors the JSON? | The dashboard does. App developers normally never write it by hand. |

Contents

Before you start

Check off these first. They are not part of this package, but nothing works without them:

  1. A CleverTap account. You need an Account ID, an Account Token, and a Region (for example in1). These come from the CleverTap dashboard.

  2. The main CleverTap SDK set up in the app. That is clevertap-react-native, installed and initialized with the credentials above. This package listens to it. See the CleverTap React Native docs.

    Already using CleverTap? Keep your existing setup as it is. Your init code, your credentials, and your native config do not change. You only add this package on top. One thing to check first: clevertap-react-native must be 4.5.0 or newer. Older apps are often on an earlier version, so confirm yours before you start. An out-of-date Core SDK is a common reason nothing renders.

  3. Know which kind of app you have - bare React Native or Expo. If you are not sure and your project has ios/ and android/ folders you edit by hand, it is bare. If you run npx expo ... commands, it is Expo.

Which setup do I need?

Follow one of the two tracks below - the one that matches your app. Do not do both. They install different packages and set CleverTap up in different ways, so mixing them will break the build.

| Your app | Follow | |---|---| | Plain React Native (has ios/ and android/ folders) | Set up - bare React Native | | Expo | Set up - Expo |

Set up - bare React Native

Bare React Native only. If your app uses Expo, skip this section and go to Set up - Expo instead.

1. Install

npm install @clevertap/native-display-sdk clevertap-react-native

clevertap-react-native is the main CleverTap SDK. If you already have it, you only need the first package.

2. Wire it up at app startup

Add this once, where your app starts (usually App.tsx):

import CleverTap from 'clevertap-react-native';
import { NativeDisplayBridge } from '@clevertap/native-display-sdk';

// Connect this renderer to the main CleverTap SDK.
NativeDisplayBridge.shared.bind(CleverTap);

// Ask CleverTap for any campaigns waiting for this user.
NativeDisplayBridge.shared.fetchNativeDisplays(CleverTap);

If your campaigns use gradients, video, web content, or blur, you also need to register the libraries that draw them - see Optional UI features. Text-only campaigns need nothing extra.

3. Show the campaign

Render campaigns with <NativeDisplayView />. See Using it in your code for a full example, and the runnable app in example/.

4. Check that it works

When a campaign's trigger event fires, your app receives the campaign and draws it. To watch this happen in the console, turn on debug logs:

import { NativeDisplayBridge, NDLogLevel } from '@clevertap/native-display-sdk';

NativeDisplayBridge.shared.setLogLevel(NDLogLevel.DEBUG);

If nothing shows up, see FAQ and troubleshooting.

Set up - Expo

Expo only. If your app is plain React Native, skip this section and use Set up - bare React Native instead.

This package is pure JavaScript, so it needs no special Expo config of its own. You set up the main CleverTap SDK for Expo, then add this package like any other JavaScript library.

1. Install

npx expo install @clevertap/native-display-sdk clevertap-react-native @clevertap/clevertap-expo-plugin
  • @clevertap/clevertap-expo-plugin sets up CleverTap's native pieces during expo prebuild (Podfile, Info.plist, AndroidManifest, lifecycle hooks).
  • clevertap-react-native must be 4.5.0 or newer.

Already have CleverTap set up in your Expo app? You only need @clevertap/native-display-sdk. The plugin and the app.json block below are already in place, so install just that one package, then skip to step 3.

2. Add the plugin to app.json

{
  "expo": {
    "plugins": [
      ["@clevertap/clevertap-expo-plugin", {
        "accountId":    "...",
        "accountToken": "...",
        "accountRegion": "in1",
        "ios":     { "mode": "development" },
        "android": { "registerActivityLifecycleCallbacks": true }
      }]
    ]
  }
}

3. Prebuild and run

npx expo prebuild --clean
npx expo run:ios       # or run:android

4. Wire it up and show the campaign

The JavaScript code to start the SDK and draw a campaign is identical on both tracks. Reuse the snippets from step 2 and step 3 above - just the code, not the bare install commands. A runnable Expo app lives in expo-example/.

Expo Go will not work. The main CleverTap SDK needs native code that Expo Go cannot load. You must use expo prebuild + expo run:*, or EAS Build.

Optional UI features

Some features of a native display template - gradients, video, web content, blur - are drawn using well-known React Native libraries. Wiring one up takes two steps: install the library, then register it with the SDK at startup (see Register them at startup below). You do both only for the libraries your campaigns actually use.

The SDK never imports these libraries itself. It uses only the ones you hand it through registerComponents. If a feature's library is not registered, the SDK falls back to a simpler look (for example, a gradient becomes a solid color) instead of crashing. So it is safe to start with none and add a library later if a template feature does not look right - just remember the second step, register it, or installing alone changes nothing.

Install all of them at once (optional)

If you would rather not think about which template feature needs which library, install the whole set in one command. Pick the block that matches your app.

Bare React Native:

npm install react-native-linear-gradient react-native-svg react-native-reanimated \
  react-native-webview react-native-video @react-native-masked-view/masked-view \
  @react-native-community/blur react-native-fast-image

Pick versions that match your React Native version. These libraries have native code, and each supports its own range of React Native versions. The command above installs the latest of each, which may be too new - or too new to build - for your React Native version. Three known traps:

  • react-native-reanimated 4.x supports only recent React Native (4.3.1 declares a React Native peer range of 0.81 - 0.85), so on React Native 0.76 you install react-native-reanimated@~3.18 instead.
  • On React Native 0.76 - 0.80 (New Architecture on by default), recent react-native-svg (15.16.0 and newer) and react-native-fast-image (10.x) fail the codegen build step with an Unknown prop type ... "undefined" error. Pin the versions the sample apps use instead: [email protected] and [email protected].
  • [email protected] has a React peer range of ^17 || ^18 - see the React 19 note below.

The least-surprise path is to copy the pinned versions from the sample app that matches your React Native version: example-rn076/package.json for React Native 0.76.x, or example/package.json for React Native 0.85.x. If a native library fails to build or the app will not start after adding one, check that library's supported React Native range and install a version that fits. Expo users avoid this: expo install (below) picks matching versions for you.

Expo (uses expo install so versions match your Expo SDK, and swaps in the Expo-native gradient and image libraries):

npx expo install expo-linear-gradient react-native-svg react-native-reanimated \
  react-native-webview react-native-video @react-native-masked-view/masked-view \
  @react-native-community/blur expo-image

Two things to know:

  • React 19 and react-native-fast-image. The version the sample apps pin, [email protected], declares a React peer range of ^17 || ^18, so on a React 19 project npm install rejects it unless you add --legacy-peer-deps. Installing it unpinned avoids the peer range - the current npm latest is 10.x with a React peer of * - but that 10.x release fails the New Architecture codegen build (see the version note above), which is why the sample apps stay on 8.6.3. You can also just drop fast-image: image loading still works through the built-in image view, only without the fast-image speedup. The Expo command avoids all of this by using expo-image instead.
  • react-native-reanimated needs a Babel plugin. After installing it, add the plugin as the last entry in babel.config.js and rebuild - see the reanimated note in FAQ and troubleshooting.

Register them at startup

Installing a library is not enough on its own. The SDK does not import these libraries. You import each one and hand it to the SDK with registerComponents. Do this once, in your app's entry file (index.js), before any campaign renders. Register only the libraries you installed.

import Video from 'react-native-video';
import LinearGradient from 'react-native-linear-gradient';
import * as Svg from 'react-native-svg';
import * as Reanimated from 'react-native-reanimated';
import { WebView } from 'react-native-webview';
import MaskedView from '@react-native-masked-view/masked-view';
import { BlurView } from '@react-native-community/blur';
import FastImage from 'react-native-fast-image';
import { registerComponents } from '@clevertap/native-display-sdk';

registerComponents({
  Video,
  LinearGradient,
  Svg,
  Reanimated,
  WebView,
  MaskedView,
  BlurView,
  FastImage,
});

Each value must match the shape the SDK reads back:

  • Default export - Video, LinearGradient, MaskedView, FastImage.
  • Named export - WebView, BlurView.
  • Whole module namespace (import * as) - Svg, Reanimated.

On Expo, swap the two libraries that have Expo-native equivalents and register them under their own keys:

import LinearGradient from 'react-native-linear-gradient'; // or expo-linear-gradient
import { Image as ExpoImage } from 'expo-image'; // named export, key "ExpoImage"

registerComponents({
  // ... the rest as above ...
  LinearGradient,
  ExpoImage, // replaces FastImage under Expo
});

The SDK prefers ExpoImage over FastImage when both are registered. Since you choose which keys to register, register the one you installed. For a complete entry file, see example/index.js (bare) or expo-example/index.js (Expo).

| Library | Powers | Expo equivalent | |---|---|---| | react-native-linear-gradient | linear gradient backgrounds | expo-linear-gradient (preferred under Expo) | | react-native-svg | radial, sweep, and pattern backgrounds | - | | react-native-reanimated | animated gradient, shimmer, pulse, particle backgrounds | - | | react-native-webview | HTML elements | - | | react-native-video | VIDEO elements | - | | @react-native-masked-view/masked-view | gradient-filled text | - | | @react-native-community/blur | blur effects | - | | react-native-fast-image | faster image loading | expo-image (preferred under Expo) |

Minimum versions are listed as peer dependencies in package.json. Under Expo you register the Expo-native gradient and image libraries in place of the bare ones - see Register them at startup.

Using it in your code

Listen for campaigns, then draw each one with <NativeDisplayView />:

import React, { useEffect, useState } from 'react';
import { ScrollView } from 'react-native';
import {
  NativeDisplayBridge,
  NativeDisplayView,
} from '@clevertap/native-display-sdk';
import type {
  NativeDisplayUnit,
  NativeDisplayBridgeListener,
} from '@clevertap/native-display-sdk';

export function Campaigns() {
  const [units, setUnits] = useState<NativeDisplayUnit[]>([]);

  useEffect(() => {
    const listener: NativeDisplayBridgeListener = {
      onNativeDisplaysLoaded(incoming) {
        setUnits(incoming);
      },
    };
    NativeDisplayBridge.shared.addListener(listener);
    return () => NativeDisplayBridge.shared.removeListener(listener);
  }, []);

  return (
    <ScrollView>
      {units.map((unit) => (
        <NativeDisplayView key={unit.unitId} unit={unit} />
      ))}
    </ScrollView>
  );
}

For placing campaigns into named slots, or handling taps and custom actions, see the runnable example/ app, which shows every integration pattern.

FAQ and troubleshooting

Do we need to change native (iOS/Android) code to use this package? No. This package is pure TypeScript. The main CleverTap SDK does need native setup - on Expo that is handled by expo prebuild.

Can we test in Expo Go? No. See the Expo Go note. Use expo prebuild + expo run:* or EAS Build.

We do not use video (or gradients). Do we still install those libraries? No. Everything under Optional UI features is optional. Install only what your campaigns use.

Which platforms are supported? iOS and Android.

Nothing is showing up. What do I check?

  1. Is the main CleverTap SDK installed and initialized with valid credentials?
  2. Did you call both NativeDisplayBridge.shared.bind(CleverTap) and fetchNativeDisplays(CleverTap) at startup?
  3. Did you register a listener with addListener and render <NativeDisplayView /> for the units you receive? Fetching alone does not draw anything on screen - see Using it in your code.
  4. Did the event that the campaign targets actually fire for this user?
  5. Did you rebuild the app after installing? On bare React Native run cd ios && pod install for iOS, then rebuild. On Expo run npx expo prebuild --clean again.
  6. Watch the SDK's own logs. The SDK prints a warning whenever a feature degrades - for example, an optional library that is not registered. These warnings show at the default level, so you do not need to raise it. To be sure the level is not turned off, set it once at startup: NativeDisplayBridge.shared.setLogLevel(NDLogLevel.INFO). Use NDLogLevel.DEBUG only if you want extra tracing detail. If you still see no SDK logs at all, read the next entry.

I see no SDK logs, or an optional feature silently does not render. The SDK reports these problems through warnings, but two things can hide them:

  1. You are running a release build. The SDK's logs are JavaScript console output. React Native release builds usually do not forward console output to logcat (Android) or the Xcode console (iOS). So a warning that a library is missing will not appear in a release build, even though the fallback still happens on screen. To read SDK logs, run a debug build.
  2. The log level was turned off by the main CleverTap SDK. Until you set a level yourself, this SDK follows the main CleverTap SDK's debug level. If that is off, this SDK goes quiet too. Set the level once at startup to force logs on: NativeDisplayBridge.shared.setLogLevel(NDLogLevel.INFO). An explicit call always wins over the main SDK's level.

If a feature is missing but you cannot see logs, first confirm the library is installed and registered - see the entry "I installed a UI library ... but the feature still does not appear" further down in this section.

I get "Unable to resolve module ..." or a red error screen right after installing. Metro (the JavaScript bundler) is using a stale list of packages. Stop it and restart with a clean cache: npx react-native start --reset-cache on bare React Native, or npx expo start --clear on Expo.

I installed a UI library (video, gradient, ...) but the feature still does not appear. Two things to check. First, did you register it? Installing a library does not wire it to the SDK on its own - you must also pass it to registerComponents at startup. See Register them at startup. Second, libraries with native code need a full app rebuild, not just a JavaScript reload. Stop the app and rebuild it. On iOS run cd ios && pod install first (bare React Native) or npx expo prebuild --clean (Expo).

If you installed react-native-reanimated for animated backgrounds, you must also add its Babel plugin as the last entry in babel.config.js, or the app can silently fail to mount on Android. The plugin name depends on your Reanimated version: for Reanimated 4 it is react-native-worklets/plugin; for Reanimated 3 it is react-native-reanimated/plugin. Rebuild after changing babel.config.js.

A gradient or video looks wrong or is missing. The library that draws it is either not installed or not registered. Installing alone is not enough - you must also pass it to registerComponents at startup. See Optional UI features and Register them at startup.

Reference and advanced

  • Campaign JSON schema - the full structure the SDK draws: JSON_STRUCTURE_REFERENCE.md.
  • How it works internally - architecture and the end-to-end render flow: ARCHITECTURE.md and HAPPY_FLOW.md.
  • How optional libraries reach the SDK - the SDK never imports the optional peer libraries. The app imports each one and passes it to registerComponents at startup. The SDK reads them back from that registry (src/optional/componentRegistry.ts). A key that was never registered means the feature degrades gracefully. This keeps the SDK bundler-agnostic - it works on Metro of any version, on Expo, and on Re.Pack, with no require of a native library from inside the SDK.
  • Expo image preference - when both ExpoImage and FastImage are registered, the SDK uses ExpoImage (src/renderer/elements/ImageElement.tsx). Since you choose which keys to register, register the one you installed.
  • Exported API - NativeDisplayBridge, NativeDisplayView, NativeDisplaySlotManager, NativeDisplaySlot, wireCleverTap, NDLogLevel, and supporting types. See src/index.ts.

License

MIT