Skip to content

Devtools streamCapture endpoints do not capture events for Next.js dynamic routes matching a stable substring #117

@siddharthsharma94

Description

@siddharthsharma94

Issue Summary

Problem: streamCapture with the endpoints array does not capture events from Next.js dynamic routes, even when a stable substring pattern (per documentation) is used.

I'm struggling to figure out how to get dynamic events to show up

Technical Details

Setup:

  • Next.js Route: app/api/a/games/[gameId]/chat/route.ts
  • Runtime URL Example: /api/a/games/${gameId}/chat (e.g., /api/a/games/game_ZUWAFrQKmL/chat)
  • Transport Config:
    transport: new DefaultChatTransport({
      api: `/api/a/games/${gameId}/chat`
    })
  • Devtools Config:
    streamCapture={{
      enabled: true,
      endpoints: ["/api/a/games"], // Stable substring per docs
      autoConnect: true,
    }}

Expected Behavior (per docs):

  • Substring matching: /api/a/games should match /api/a/games/game_ZUWAFrQKmL/chat
  • The interceptor should patch window.fetch and capture streaming events

Actual Behavior:

  • State tracking works (messages, status)
  • Events/tools are not captured
  • onEvent callback never fires
  • No events appear in devtools panel

What Works:

  • Static route /api/chat works with endpoints: ["/api/chat"]
  • State management via @ai-sdk-tools/store works correctly
    This worked for me
const { messages, sendMessage, status } = useChat({
    transport: new DefaultChatTransport({
      // api: `/api/a/games/${gameId}/chat`, <--- uncommenting this does not work 
      body: {
        gameId,
      },
    }),
  });

So if the route is not dynamic events show up fine.

Environment:

  • Next.js 16.0.0 (App Router)
  • @ai-sdk-tools/devtools latest
  • @ai-sdk-tools/store latest
  • Using DefaultChatTransport from ai package

This issue contains enough context and reproduction steps to assist with investigation. Please advise on substring matching for dynamic routes and any known compatibility caveats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions