Command Palette

Search for a command to run...

Hectal
Phase 5: The Vercel AI SDK
AI Frontend · Exercise 1 of 6Next
Beginner

Show a Chat with useChat

The route /api/chat is ready. The page has a button #ask, a list #messages and a line #status. Use useChat so that clicking #ask sends the message How long does shipping take?.

Show every message of the chat inside #messages as one <p> per message (the text of its text parts), and show the chat's status in #status.

What Check tests

  1. Before the click, #status says ready and #messages is empty
  2. Right after the click the question is in #messages and #status is no longer ready
  3. At the end there are two messages and #status says ready

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.