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 🙏

© 2025 – Pkg Stats / Ryan Hefner

runanywhere-react-native

v0.1.3

Published

RunAnywhere SDK for React Native - On-device AI with intelligent routing

Readme

RunAnywhere React Native SDK

On-device AI with intelligent routing between on-device and cloud execution for optimal cost and privacy.

📖 Complete Documentation: See STATUS.md for comprehensive status, architecture, Swift SDK alignment, and implementation details.

Installation

npm install @runanywhere/react-native-sdk
# or
yarn add @runanywhere/react-native-sdk

iOS Setup

cd ios && pod install

Android Setup

No additional setup required. The module will be automatically linked.

Quick Start

import { RunAnywhere, SDKEnvironment } from '@runanywhere/react-native-sdk';

// Initialize the SDK
await RunAnywhere.initialize({
  apiKey: 'your-api-key',
  baseURL: 'https://api.runanywhere.com',
  environment: SDKEnvironment.Production,
});

// Simple chat
const response = await RunAnywhere.chat('Hello, how are you?');
console.log(response);

// With options
const result = await RunAnywhere.generate('Explain quantum computing', {
  maxTokens: 200,
  temperature: 0.7,
});
console.log('Text:', result.text);
console.log('Tokens:', result.tokensUsed);
console.log('Speed:', result.performanceMetrics.tokensPerSecond, 'tok/s');

Features

  • Text Generation: Simple chat and advanced generation with options
  • Streaming: Real-time token streaming for responsive UI
  • Voice: Speech-to-text and text-to-speech capabilities
  • Model Management: Download, load, and manage AI models
  • Events: Subscribe to SDK events for real-time updates
  • Cross-Platform: iOS and Android support

API Reference

Initialization

// Initialize SDK
await RunAnywhere.initialize({
  apiKey: string,
  baseURL: string,
  environment?: SDKEnvironment, // default: Production
});

// Check initialization state
const isInit = await RunAnywhere.isInitialized();
const isActive = await RunAnywhere.isActive();

// Reset SDK
await RunAnywhere.reset();

Text Generation

// Simple chat
const response = await RunAnywhere.chat('Hello!');

// With options
const result = await RunAnywhere.generate('Prompt', {
  maxTokens: 100,
  temperature: 0.7,
  topP: 1.0,
  systemPrompt: 'You are a helpful assistant.',
});

// Streaming
const unsubscribe = RunAnywhere.events.onGeneration((event) => {
  if (event.type === 'tokenGenerated') {
    process.stdout.write(event.token);
  }
});
const sessionId = await RunAnywhere.generateStream('Tell me a story');

Model Management

// List available models
const models = await RunAnywhere.availableModels();

// Load a model
await RunAnywhere.loadModel('llama-3.2-1b');

// Get current model
const current = await RunAnywhere.currentModel();

// Download a model (with progress events)
RunAnywhere.events.onModel((event) => {
  if (event.type === 'downloadProgress') {
    console.log(`Progress: ${event.progress * 100}%`);
  }
});
await RunAnywhere.downloadModel('llama-3.2-1b');

Voice

// Load STT model
await RunAnywhere.loadSTTModel('whisper-base');

// Transcribe audio
const result = await RunAnywhere.transcribe(audioBase64);
console.log('Transcript:', result.text);

// Load TTS model
await RunAnywhere.loadTTSModel('en-US-default');

// Synthesize speech
const audioData = await RunAnywhere.synthesize('Hello, world!', {
  voice: 'en-US-default',
  rate: 1.0,
});

Events

// Subscribe to generation events
const unsubscribe = RunAnywhere.events.onGeneration((event) => {
  switch (event.type) {
    case 'started':
      console.log('Generation started');
      break;
    case 'tokenGenerated':
      console.log('Token:', event.token);
      break;
    case 'completed':
      console.log('Done:', event.response);
      break;
    case 'failed':
      console.error('Error:', event.error);
      break;
  }
});

// Unsubscribe when done
unsubscribe();

Conversation

// Multi-turn conversation
const conversation = RunAnywhere.conversation();

const response1 = await conversation.send('Hello!');
const response2 = await conversation.send('What did I just say?');

console.log(conversation.history);
conversation.clear();

Types

The SDK exports all TypeScript types for full type safety:

import {
  // Enums
  SDKEnvironment,
  ExecutionTarget,
  LLMFramework,
  ModelCategory,
  ModelFormat,
  ComponentState,

  // Interfaces
  GenerationResult,
  GenerationOptions,
  ModelInfo,
  STTResult,
  TTSConfiguration,

  // Events
  SDKGenerationEvent,
  SDKModelEvent,
  SDKVoiceEvent,

  // Errors
  SDKError,
  SDKErrorCode,
} from '@runanywhere/react-native-sdk';

Requirements

  • React Native 0.71+
  • iOS 14.0+
  • Android API 24+

Development Setup

After cloning the repository, you need to generate the Nitrogen binding files before building:

cd sdk/runanywhere-react-native

# Install dependencies
npm install

# Generate Nitrogen bindings (REQUIRED before first build)
npm run nitrogen

What is Nitrogen?

Nitrogen is the code generator for NitroModules - a high-performance native module system for React Native. It generates:

  • C++ bridge code - Type-safe bindings between JS and native
  • Swift/Kotlin code - Platform-specific implementations
  • Autolinking files - For CocoaPods and Gradle integration

The generated files are in nitrogen/generated/ and are gitignored (auto-generated on each machine).

Native Binaries

Native binaries (XCFramework for iOS, .so libraries for Android) are automatically downloaded from runanywhere-binaries releases:

  • iOS: Downloaded during pod install via the podspec's prepare_command
  • Android: Downloaded during Gradle's preBuild phase via downloadNativeLibs task

The version is controlled by native-version.txt in the SDK root.

Build Commands

# iOS
cd examples/react-native/RunAnywhereAI/ios
pod install
cd ..
npx react-native run-ios

# Android  
cd examples/react-native/RunAnywhereAI
npx react-native run-android

License

MIT