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

@weaveai/react-native

v1.2.1

Published

React Native integration for Weave AI framework

Readme

Weave React Native

React Native hooks that bridge the Weave AI framework into mobile apps. Pair native UI with shared controllers for AI execution, chat, caching, and provider routing.

Highlights

  • Execution-aware hooksuseAI, useGenerateAI, useClassifyAI, and useExtractAI expose budgeting, cost tracking, and error handling from the shared AIExecutionController.
  • Streaming chatuseAIChat powers multi-turn conversations with message persistence, overflow summarisation, and streaming updates.
  • Cache insightsuseCache surfaces cache hits, misses, and savings so you can optimise mobile bandwidth.
  • Provider awarenessuseProviderRouting keeps dashboards in sync with the UIAwareProviderRouter from @weaveai/core.

Installation

npm install @weaveai/core @weaveai/react-native
# or
yarn add @weaveai/core @weaveai/react-native

Quick Start

import { useGenerateAI } from '@weaveai/react-native';
import { Weave } from '@weaveai/core';
import { useEffect } from 'react';
import { SafeAreaView, Text, Button, ActivityIndicator } from 'react-native';

const weave = await Weave.createAsync({
  provider: { type: 'openai', apiKey: process.env.WEAVE_OPENAI_KEY! },
});

export function InspirationCard() {
  const { generate, data, loading, cost } = useGenerateAI(weave, {
    trackCosts: true,
  });

  useEffect(() => {
    void generate('Write a short, uplifting message for teammates.');
  }, [generate]);

  return (
    <SafeAreaView>
      {loading && <ActivityIndicator />}
      {data && <Text>{data.data.text}</Text>}
      {cost && <Text>Cost: ${cost.totalCost.toFixed(4)}</Text>}
      <Button title="Generate again" onPress={() => generate('Share another motivational note.')} />
    </SafeAreaView>
  );
}

Chat Experiences

import { useAIChat } from '@weaveai/react-native';
import { FlatList, Text, View, TextInput, Button } from 'react-native';
import { useState } from 'react';

export function ConciergeChat({ weave }: { weave: Weave }) {
  const chat = useAIChat(weave, {
    systemPrompt: 'You are a helpful concierge.',
    streaming: { enabled: true, renderer: 'markdown' },
    persistence: { localStorage: 'concierge-chat', autoSave: true },
  });
  const [input, setInput] = useState('');

  const send = async () => {
    if (!input.trim()) return;
    await chat.sendMessage(input);
    setInput('');
  };

  return (
    <View style={{ flex: 1 }}>
      <FlatList
        data={chat.messages}
        keyExtractor={(_, index) => index.toString()}
        renderItem={({ item }) => (
          <View>
            <Text>
              {item.role}: {item.content}
            </Text>
          </View>
        )}
      />
      <TextInput value={input} onChangeText={setInput} placeholder="Ask anything…" />
      <Button title="Send" onPress={send} disabled={chat.isLoading} />
    </View>
  );
}

Cache & Routing

import { useCache, useProviderRouting } from '@weaveai/react-native';
import type { CacheConfig, UIAwareProviderRouter } from '@weaveai/core';

const cacheConfig: CacheConfig = {
  enabled: true,
  strategy: 'semantic',
  ttl: 900,
};

export function CacheAwarePrompt({ prompt }: { prompt: string }) {
  const cache = useCache({ cacheConfig });

  useEffect(() => {
    cache.queryCache(prompt).then((hit) => {
      if (!hit) {
        // call weave.generate here and then store the result
      }
    });
  }, [cache, prompt]);

  return null;
}

export function ProviderSummary({ router }: { router: UIAwareProviderRouter }) {
  const routing = useProviderRouting(router, { autoRefresh: true });

  return (
    <View>
      {routing.providers.map((provider) => (
        <View key={provider.name}>
          <Text>{provider.name}</Text>
          <Text>Status: {provider.healthy ? 'Healthy' : 'Offline'}</Text>
        </View>
      ))}
    </View>
  );
}

Examples

The examples directory includes self-contained snippets:

  • InspirationCard.tsxuseGenerateAI for optimistic copy creation.
  • ConciergeChat.tsx – streaming chat interface using useAIChat.
  • CacheInspector.ts – integrate cache events, stats, and savings.
  • ProviderHub.tsx – render provider status and routing events.

Import the examples into any Expo or bare React Native app after configuring a Weave instance. All hooks share the controllers defined in @weaveai/shared, so behaviour matches the React, Vue, Angular, and Svelte bindings.