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

mnn.rn

v0.1.1

Published

Ract native bindings for MNN framework from Alibaba

Readme

MNN React Native

On-device LLM inference for React Native for Alibabas MNN.

As of now this library only supports Android.

License: MIT

Features

  • 🚀 Fast on-device LLM inference - Powered by MNN engine
  • 📱 React Native native modules - TurboModule architecture
  • 🔄 Streaming text generation - Real-time token-by-token output
  • 💬 Conversation support - Multi-turn chat with history
  • Optimized for mobile - ARM64 optimized with quantization support
  • 🎯 Type-safe API - Full TypeScript support
  • 🔧 Flexible configuration - Runtime config updates

Installation

npm install mnn.rn
# or
yarn add mnn.rn

Quick Start

import { createMnnLlmSession } from 'mnn.rn';

const session = createMnnLlmSession();

// Initialize
await session.init({
  modelDir: '/sdcard/models/llama-3-8b',
  maxNewTokens: 2048,
  systemPrompt: 'You are a helpful AI assistant.',
  keepHistory: true
});

// Generate with streaming - now returns Promise!
const metrics = await session.submitPrompt(
  'Write a haiku about React Native',
  true,
  (chunk) => console.log(chunk),      // Each token
  (metrics) => console.log('Done!'),  // Completion callback
  (error) => console.error(error)     // Errors
);

console.log('Generated', metrics.decodeLen, 'tokens');

// Clean up
await session.release();

See QUICK_START.md for detailed usage examples.

API Overview

Session Lifecycle

// Create session
const session = createMnnLlmSession();

// Initialize with model
await session.init({
  modelDir: string,
  maxNewTokens?: number,
  systemPrompt?: string,
  keepHistory?: boolean
});

// Release resources
await session.release();

Text Generation

// Streaming with callbacks AND Promise (recommended)
const metrics = await session.submitPrompt(
  prompt: string,
  keepHistory: boolean,
  onChunk?: (chunk: string) => void,
  onComplete?: (metrics: LlmMetrics) => void,
  onError?: (error: string) => void
): Promise<LlmMetrics>

// Conversation with history
const metrics = await session.submitWithHistory(
  messages: LlmMessage[],
  onChunk?: (chunk: string) => void,
  onComplete?: (metrics: LlmMetrics) => void,
  onError?: (error: string) => void
): Promise<LlmMetrics>

// Stop generation
await session.stop();

Configuration

// Update settings at runtime
await session.updateMaxNewTokens(512);
await session.updateSystemPrompt('You are a helpful assistant.');
await session.updateConfig(JSON.stringify({ temperature: 0.7 }));

// Manage conversation
await session.clearHistory();
await session.reset();

// Stop ongoing generation
await session.stop();

See API.md for complete API reference.

Example App

Run the included example:

cd example
npm install
npm run android

Features demonstrated:

  • ✅ Model initialization
  • ✅ Real-time streaming
  • ✅ Token counter
  • ✅ Performance metrics
  • ✅ Conversation history
  • ✅ Example prompts

Architecture

┌─────────────────────────┐
│   React Native App      │  TypeScript API
├─────────────────────────┤
│   TurboModule Bridge    │  React Native Bridge
├─────────────────────────┤
│   Kotlin Module         │  Session Management
├─────────────────────────┤
│   JNI Layer             │  Callback Bridge
├─────────────────────────┤
│   C++ LlmSession        │  MNN Wrapper
├─────────────────────────┤
│   libMNN.so             │  Inference Engine
└─────────────────────────┘

Model Preparation

  1. Convert your model to MNN format using MNN tools
  2. Place on device:
    adb push /path/to/model /sdcard/models/your-model/
  3. Model structure:
    /sdcard/models/your-model/
    ├── model.mnn
    ├── tokenizer.txt
    └── config.json

Requirements

  • React Native 0.71+
  • Android:
    • NDK r21+
    • Gradle 8.0+
    • ARM64 device (arm64-v8a)
  • iOS: Coming soon

Common Issues

"Session is not initialized"

  • Solution: Call init() before using the session

"Model not found"

  • Solution: Verify model path with adb shell ls /sdcard/models/your-model

Slow performance

  • Solution: Use quantized models (4-bit or 8-bit)
  • Solution: Reduce maxNewTokens
  • Solution: Use smaller model size

Out of memory

  • Solution: Use smaller model
  • Solution: Clear history more frequently
  • Solution: Close other apps

See QUICK_START.md for more details.

Documentation

Contributing

Contributions are welcome! Please read our Contributing Guide.

License

MIT License - see LICENSE file for details.

Acknowledgments

  • MNN - Mobile Neural Network inference framework
  • React Native team for TurboModule architecture

Support

  • GitHub Issues: [Report bugs or request features]
  • Documentation: See files above
  • Example App: Run cd example && npm run android

Built with ❤️ by Naved Merchant