@ai-sdk/react 4.0.156 → 4.0.158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +59 -3
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @ai-sdk/react
2
2
 
3
+ ## 4.0.158
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [47236dd]
8
+ - Updated dependencies [c8e8866]
9
+ - Updated dependencies [e64ed82]
10
+ - Updated dependencies [1cf95c6]
11
+ - ai@7.0.154
12
+ - @ai-sdk/provider-utils@5.0.69
13
+ - @ai-sdk/mcp@2.0.85
14
+
15
+ ## 4.0.157
16
+
17
+ ### Patch Changes
18
+
19
+ - e729d58: chore(docs): update `README.md` for consistent format and to avoid duplication
20
+ - Updated dependencies [84d7880]
21
+ - Updated dependencies [5475347]
22
+ - Updated dependencies [e729d58]
23
+ - @ai-sdk/mcp@2.0.84
24
+ - @ai-sdk/provider@4.0.34
25
+ - ai@7.0.153
26
+ - @ai-sdk/provider-utils@5.0.68
27
+
3
28
  ## 4.0.156
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -2,6 +2,62 @@
2
2
 
3
3
  [React](https://react.dev/) UI components for the [AI SDK](https://ai-sdk.dev/docs):
4
4
 
5
- - [`useChat`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) hook
6
- - [`useCompletion`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-completion) hook
7
- - [`useObject`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-object) hook
5
+ ## Setup
6
+
7
+ ```bash
8
+ npm i ai @ai-sdk/react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ 'use client';
15
+
16
+ import { useChat } from '@ai-sdk/react';
17
+ import { DefaultChatTransport } from 'ai';
18
+ import { useState } from 'react';
19
+
20
+ export default function Page() {
21
+ const { messages, sendMessage, status } = useChat({
22
+ transport: new DefaultChatTransport({
23
+ api: '/api/chat',
24
+ }),
25
+ });
26
+ const [input, setInput] = useState('');
27
+
28
+ return (
29
+ <>
30
+ {messages.map(message => (
31
+ <div key={message.id}>
32
+ {message.role === 'user' ? 'User: ' : 'AI: '}
33
+ {message.parts.map((part, index) =>
34
+ part.type === 'text' ? <span key={index}>{part.text}</span> : null,
35
+ )}
36
+ </div>
37
+ ))}
38
+
39
+ <form
40
+ onSubmit={e => {
41
+ e.preventDefault();
42
+ if (input.trim()) {
43
+ sendMessage({ text: input });
44
+ setInput('');
45
+ }
46
+ }}
47
+ >
48
+ <input
49
+ value={input}
50
+ onChange={e => setInput(e.target.value)}
51
+ disabled={status !== 'ready'}
52
+ placeholder="Say something..."
53
+ />
54
+ <button type="submit" disabled={status !== 'ready'}>
55
+ Submit
56
+ </button>
57
+ </form>
58
+ </>
59
+ );
60
+ }
61
+ ```
62
+
63
+ See the [React documentation](https://ai-sdk.dev/docs/ai-sdk-ui/chatbot) for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/react",
3
- "version": "4.0.156",
3
+ "version": "4.0.158",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -26,10 +26,10 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@ai-sdk/mcp": "2.0.83",
30
- "@ai-sdk/provider": "4.0.33",
31
- "@ai-sdk/provider-utils": "5.0.67",
32
- "ai": "7.0.152",
29
+ "@ai-sdk/mcp": "2.0.85",
30
+ "@ai-sdk/provider": "4.0.34",
31
+ "@ai-sdk/provider-utils": "5.0.69",
32
+ "ai": "7.0.154",
33
33
  "swr": "^2.4.1",
34
34
  "throttleit": "2.1.0"
35
35
  },