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

react-native-nucleus

v0.3.3

Published

Core infrastructure for React Native applications, providing the basics to avoid repeating yourself when bootstrapping a new app.

Readme

React Native Nucleus

Core infrastructure for React Native applications, providing a robust foundation for subscription management and state persistence.

Features

  • RevenueCat Integration: Seamless wrapper around react-native-purchases.
  • Subscription Store: Powered by Zustand and MMKV for high-performance persistence.
  • Type Safety: Built with strict TypeScript rules.

Installation

npm install react-native-nucleus react-native-purchases zustand react-native-mmkv @react-native-community/netinfo
# or
yarn add react-native-nucleus react-native-purchases zustand react-native-mmkv @react-native-community/netinfo

Setup

Wrap your application with AppCoreProvider.

import { AppCoreProvider, NucleusConfig } from 'react-native-nucleus';
import * as appTranslations from './locales/translations';

// Best practice: Derive supported languages from your translations object
const supportedLanguages = Object.keys(appTranslations) as (keyof typeof appTranslations)[];

const config: NucleusConfig = {
  revenueCat: {
    iosApiKey: 'your_ios_key',
    androidApiKey: 'your_android_key',
    // Required: Triggered when the paywall flow is finished (success, error, or cancel)
    onPaywallFlowEnd: () => {
      // e.g., router.push('/home') or closing a modal
      console.log('Paywall flow finished');
    },
  },
};

export default function App() {
  return (
    <AppCoreProvider config={config}>
      <YourAppContent />
    </AppCoreProvider>
  );
}

Usage

State Management (Zustand)

Nucleus provides two hooks to access the same global store, allowing for better semantic clarity in your components:

  • useAppCoreStore: General access to the entire state (isPro, language, etc).

Important: Always use specific selectors to avoid unnecessary re-renders.

Accessing Subscription State

import { useAppCoreStore } from 'react-native-nucleus';

const MyComponent = () => {
  // Use a selector to only subscribe to isPro changes
  const isPro = useAppCoreStore((state) => state.isPro);

  if (isPro) {
    return <PremiumContent />;
  }

  return <LockedContent />;
};

Managing Language

import { useAppCoreStore } from 'react-native-nucleus';

const LanguageSwitcher = () => {
  const language = useAppCoreStore((state) => state.language);
  const { setLanguage } = useAppCoreStore.getState();


  return (
    <Button 
      title={`Current: ${language}. Change to PT`} 
      onPress={() => setLanguage('pt')} 
    />
  );
};

Managing Purchases

Use the purchaseService to handle purchases and restorations imperatively.

import { purchaseService } from 'react-native-nucleus';

const restore = async () => {
  try {
    // Automatically updates the store state on success
    await purchaseService.restorePurchases();
  } catch (error) {
    console.error(error);
  }
};

Paywalls & Customer Center

To use RevenueCat's Paywalls and Customer Center, you need to install react-native-purchases-ui.

npm install react-native-purchases-ui

Then you can use the built-in methods in purchaseService:

import { purchaseService } from 'react-native-nucleus';

// Present Paywall (returns true if purchased/restored)
// Note: This also triggers the global `onPaywallFlowEnd` callback if configured
const showPaywall = async () => {
  const purchased = await purchaseService.presentPaywall();
  if (purchased) {
    console.log('User is now Pro!');
  }
};

// Present Customer Center
const showCustomerCenter = async () => {
  await purchaseService.presentCustomerCenter();
};

Configuration

| Property | Type | Description | | :--- | :--- | :--- | | revenueCat.iosApiKey | string | RevenueCat API Key for iOS | | revenueCat.androidApiKey | string | RevenueCat API Key for Android | | revenueCat.onPaywallFlowEnd | () => void | Callback triggered when paywall flow finishes (success, error, or cancel) |


## Testing

When testing components that use `react-native-nucleus`, you should mock the store and services.

### Jest Mock Example

```javascript
jest.mock('react-native-nucleus', () => ({
  useAppCoreStore: (selector) =>
    selector({
      isPro: true,
      language: 'en',
      setIsPro: jest.fn(),
      setLanguage: jest.fn(),
      resetSubscription: jest.fn(),
    }),
  purchaseService: {
    restorePurchases: jest.fn(),
    purchasePackage: jest.fn(),
  },
}));

Architecture

  • Store: Zustand with MMKV persistence.
  • Services: Singleton classes for external integrations.