open-index/open-npm huggingface dataset:
npm package: @reminix/react
Description: Reminix React SDK - hooks and components for React applications
Author: Reminix Team
Latest version: 0.0.8

# @reminix/react

React SDK for Reminix - hooks and components for React applications.

## Installation

```bash
npm install @reminix/react
```

Note: `@reminix/client` is included as a dependency.

## Quick Start

```tsx
import { ReminixProvider, useChatAgent } from '@reminix/react';

function App() {
  return (
    <ReminixProvider clientToken="your-client-token">
      <ChatComponent />
    </ReminixProvider>
  );
}

function ChatComponent() {
  const { chat, data, isLoading, error } = useChatAgent('my-agent');

  const handleSend = async () => {
    await chat({
      messages: [{ role: 'user', content: 'Hello!' }],
    });
  };

  return (
    <div>
      {isLoading && <p>Loading...</p>}
      {error && <p>Error: {error.message}</p>}
      {data && <p>{data.messages[0]?.content}</p>}
      <button onClick={handleSend}>Send</button>
    </div>
  );
}
```

## Streaming

```tsx
function StreamingChat() {
  const { chatStream, isLoading } = useChatAgent('my-agent');
  const [text, setText] = useState('');

  const handleStream = async () => {
    setText('');
    await chatStream(
      { messages: [{ role: 'user', content: 'Tell me a story' }] },
      (chunk) => setText((prev) => prev + chunk.chunk)
    );
  };

  return (
    <div>
      <pre>{text}</pre>
      <button onClick={handleStream} disabled={isLoading}>
        {isLoading ? 'Streaming...' : 'Start Stream'}
      </button>
    </div>
  );
}
```

## API

### Provider

#### `ReminixProvider`

Wrap your app with this provider to use Reminix hooks.

```tsx
<ReminixProvider clientToken="..." baseUrl="...">
  {children}
</ReminixProvider>
```

### Hooks

#### `useReminixClient()`

Returns the raw `ReminixClient` instance for advanced usage.

#### `useChatAgent(agentName)`

Hook for chatting with an agent.

Returns:
- `chat(request)` - Send a chat message (non-streaming)
- `chatStream(request, onChunk)` - Send a streaming chat message
- `data` - Latest response
- `error` - Error if request failed
- `isLoading` - Loading state
- `reset()` - Reset state

#### `useInvokeAgent(agentName)`

Hook for invoking an agent.

Returns:
- `invoke(request)` - Invoke agent (non-streaming)
- `invokeStream(request, onChunk)` - Invoke with streaming
- `data` - Latest response
- `error` - Error if request failed
- `isLoading` - Loading state
- `reset()` - Reset state

## License

Apache-2.0