Skip to content

Dev Tools

Next.js 17 Has The AI SDK Built In Now

Zero install, full vendor lock-in

🤖📦

If you've been living under a rock, Next.js 17 dropped with the Vercel AI SDK folded into core. No npm install ai, no version mismatch dance, just import and go. Convenient. Maybe too convenient.

The Setup

The full generateText and streamUI surface area now lives at next/ai. Provider plugins still install separately, but the core SDK is in the framework now.

{`// app/api/chat/route.ts
import { generateText, streamText } from "next/ai";
import { anthropic } from "@ai-sdk/anthropic";

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = await streamText({
    model: anthropic("claude-haiku-4-7"),
    messages,
    maxTokens: 1024,
  });

  return result.toDataStreamResponse();
}`}

The Money Pattern

The real win is streamUI — server components that render LLM-generated tool calls as actual JSX. I'm prototyping a Rebuild Relief lead-triage flow where the LLM emits typed components and Next renders them inline. Genuinely cool, drops a ton of boilerplate.

{`// app/triage/page.tsx
import { streamUI } from "next/ai";
import { openai } from "@ai-sdk/openai";

export default async function Page() {
  const ui = await streamUI({
    model: openai("gpt-4o-mini"),
    prompt: "triage this lead and pick an action",
    tools: {
      assignRep: {
        description: "assign a sales rep",
        parameters: z.object({ repId: z.string() }),
        generate: async ({ repId }) => ,
      },
    },
  });

  return 
{ui.value}
; }`}

The Catch

This is vendor lock-in dressed up as DX. Vercel owns the framework, ships their own SDK in it, optimises for their hosting. Self-host on Netlify and most of it still works, but every release tightens the gravity well. Worth knowing what you're signing up for.

The Verdict

If you're already all-in on Vercel, this is fantastic. If you're shipping on Netlify or self-hosting, watch this carefully — the SDK is good enough that lifting it out post-hoc will get painful. For my Astro projects I'm sticking with the standalone ai package, which still works fine without the framework hug.

Let us make some quick suggestions?

Please provide your full name.
Please provide your phone number.
Please provide a valid phone number.
Please provide your email address.
Please provide a valid email address.
Please provide your brand name or website.
Please provide your brand name or website.