@ai-sdk/react 4.0.155 → 4.0.157

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 +19 -0
  2. package/README.md +59 -3
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/react
2
2
 
3
+ ## 4.0.157
4
+
5
+ ### Patch Changes
6
+
7
+ - e729d58: chore(docs): update `README.md` for consistent format and to avoid duplication
8
+ - Updated dependencies [84d7880]
9
+ - Updated dependencies [5475347]
10
+ - Updated dependencies [e729d58]
11
+ - @ai-sdk/mcp@2.0.84
12
+ - @ai-sdk/provider@4.0.34
13
+ - ai@7.0.153
14
+ - @ai-sdk/provider-utils@5.0.68
15
+
16
+ ## 4.0.156
17
+
18
+ ### Patch Changes
19
+
20
+ - ai@7.0.152
21
+
3
22
  ## 4.0.155
4
23
 
5
24
  ### 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.155",
3
+ "version": "4.0.157",
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.151",
29
+ "@ai-sdk/mcp": "2.0.84",
30
+ "@ai-sdk/provider": "4.0.34",
31
+ "@ai-sdk/provider-utils": "5.0.68",
32
+ "ai": "7.0.153",
33
33
  "swr": "^2.4.1",
34
34
  "throttleit": "2.1.0"
35
35
  },