Skip to content
Source
Sign inSign up
TanStack/ai

Add TanStack Start server code example for chat API #141

Mergedharlley(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/141/headmerged by AlemTuzlak View on GitHub

The Next.js-only code was confusing for a beginner unfamiliar with Tanstack syntax.

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Documentation
    • Added a TanStack Start Quick Start example demonstrating a complete chat API endpoint with streaming responses and error handling.
    • Replaced the previous Next.js header with the new TanStack Start block and simplified the Next.js snippet to retain only essential imports.
    • Improved guidance for implementing streaming chat endpoints in the Quick Start.
✏️ Tip: You can customize this high-level summary in your review settings.
    1. Walkthrough

      Added a TanStack Start server POST /api/chat example to the quick-start docs demonstrating OPENAI_API_KEY validation, request parsing (messages, conversationId), streaming chat via chat({ adapter: openai(), ... }) converted to an HTTP stream with toStreamResponse, and JSON 500 error handling; adjusted the Next.js snippet imports.

      Changes

      Cohort / File(s)Summary
      Quick-start documentation updates
      docs/getting-started/quick-start.md
      Added a TanStack Start POST /api/chat API route example (OPENAI_API_KEY validation, parsing messages and conversationId, streaming chat via chat({ adapter: openai(), ... }), converting to HTTP stream with toStreamResponse, and JSON 500 error handling). Replaced Next.js placeholder header with remaining import statements.

      Estimated code review effort

      🎯 1 (Trivial) | ⏱️ ~5 minutes

      • Documentation-only change with code examples.
      • Reviewers should spot-check example correctness:
        • Ensure imports and function names (chat, openai, toStreamResponse) match library API.
        • Verify environment variable name and error responses.
        • Confirm snippet syntax is valid for the target runtime (TanStack Start / Next.js).

      Poem

      🥕 I nibble docs by lantern light, Wove a chat route smooth and bright, Keys guarded, streams set free to roam, Snippets tucked into their home, Hop — the quick-start feels just right.

      Pre-merge checks and finishing touches

      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title accurately summarizes the main change: adding a TanStack Start server code example for the chat API, which directly matches the file changes in the quick-start.md documentation.
      Description check✅ PassedThe description follows the template structure with checked checklists and clear release impact designation. The Changes section is minimally filled but adequate context is provided in the introductory statement about addressing beginner confusion.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      ✨ Finishing touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment

      📜 Recent review details

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 5a905396141e99e83eb79d6554da7dadeea2f55c and 2b3543e673b4d75b29cb2c26f8eaf43dd0794234.

      📒 Files selected for processing (1)
      • docs/getting-started/quick-start.md (1 hunks)
      🚧 Files skipped from review as they are similar to previous changes (1)
      • docs/getting-started/quick-start.md

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. Actionable comments posted: 1

      📜 Review details

      Configuration used: CodeRabbit UI

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 049eb8acd83e6d566c6040c0c4cb53dbe222d46a and f07605b289d376c3c1a77868b1058e34fade2b72.

      📒 Files selected for processing (1)
      • docs/getting-started/quick-start.md (1 hunks)
      🧰 Additional context used
      🪛 markdownlint-cli2 (0.18.1)
      docs/getting-started/quick-start.md

      30-30: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      31-31: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      32-32: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      33-33: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      34-34: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      35-35: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      36-36: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      37-37: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      38-38: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      39-39: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      40-40: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      41-41: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      42-42: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      43-43: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      44-44: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      46-46: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      48-48: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      49-49: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      50-50: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      51-51: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      52-52: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      53-53: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      54-54: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      55-55: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      57-57: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      58-58: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      59-59: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      60-60: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      61-61: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      62-62: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      63-63: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      64-64: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      65-65: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      66-66: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      67-67: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      68-68: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      69-69: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      70-70: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      71-71: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      72-72: Hard tabs Column: 1

      (MD010, no-hard-tabs)


      73-73: Hard tabs Column: 1

      (MD010, no-hard-tabs)

      🔇 Additional comments (1)
      docs/getting-started/quick-start.md (1)

      22-122: Well-structured examples demonstrating equivalent functionality across frameworks.

      The addition of the TanStack Start example alongside the Next.js implementation is excellent for documentation clarity. Both examples properly demonstrate:

      • Environment variable validation
      • Request parsing with conversationId and messages
      • Streaming chat response creation via the chat() API
      • Proper error handling with JSON error responses

      The parallel structure makes it easy for developers familiar with either framework to understand how to implement the same functionality.

      OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)
    3. AlemTuzlak approved these changes

    4. AlemTuzlak merged this254b248

    5. AlemTuzlak closed this

Sign in to join this conversation.