1. A startup is building a customer support chatbot using Next.js and the Vercel AI SDK. Users are complaining that the interface feels unresponsive because they see nothing until the full response arrives. Which combination of server-side and client-side changes will deliver the best perceived performance improvement?
- A. Use a standard REST endpoint that returns JSON, and poll the endpoint every 500 ms from the client.
- B. Switch the Next.js API route to use a streaming response with Server-Sent Events (SSE), and render tokens incrementally on the client with the AI SDK's `useChat` hook.✓ Correct
- C. Increase the server's timeout limit to 120 seconds so the full response can be generated before sending.
- D. Pre-generate all possible responses offline and serve them from a CDN edge cache.
Explanation
Option B is correct. Streaming via SSE allows the server to push each token to the client as it is generated. The AI SDK's `useChat` hook is purpose-built to consume this stream and append tokens to the UI incrementally, giving users immediate visual feedback. — Option A (polling) introduces latency between poll intervals and is wasteful on server resources; it does not provide token-by-token rendering. — Option C simply extends the silent wait; the user still sees nothing until the full response is ready, worsening the experience. — Option D is only feasible for a tiny, static FAQ set and is entirely impractical for an open-domain support chatbot.