Skip to content

Commit e5deeae

Browse files
authored
chore (docs): update AI SDK UI README section (vercel#5383)
1 parent 0e51156 commit e5deeae

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

packages/ai/README.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,20 @@ console.log(text);
4343

4444
### AI SDK UI
4545

46-
The [AI SDK UI](https://sdk.vercel.ai/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, Vue, and SolidJS.
46+
The [AI SDK UI](https://sdk.vercel.ai/docs/ai-sdk-ui/overview) module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, and Vue.
47+
48+
You need to install the package for your framework:
49+
50+
```shell
51+
npm install @ai-sdk/react
52+
```
4753

4854
###### @/app/page.tsx (Next.js App Router)
4955

5056
```tsx
5157
'use client';
5258

53-
import { useChat } from 'ai/react';
59+
import { useChat } from '@ai-sdk/react';
5460

5561
export default function Page() {
5662
const { messages, input, handleSubmit, handleInputChange, status } =
@@ -60,8 +66,15 @@ export default function Page() {
6066
<div>
6167
{messages.map(message => (
6268
<div key={message.id}>
63-
<div>{message.role}</div>
64-
<div>{message.content}</div>
69+
<strong>{`${message.role}: `}</strong>
70+
{message.parts.map((part, index) => {
71+
switch (part.type) {
72+
case 'text':
73+
return <span key={index}>{part.text}</span>;
74+
75+
// other cases can handle images, tool calls, etc
76+
}
77+
})}
6578
</div>
6679
))}
6780

0 commit comments

Comments
 (0)