-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
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/gamesshould match/api/a/games/game_ZUWAFrQKmL/chat - The interceptor should patch
window.fetchand capture streaming events
Actual Behavior:
- State tracking works (messages, status)
- Events/tools are not captured
onEventcallback never fires- No events appear in devtools panel
What Works:
- Static route
/api/chatworks withendpoints: ["/api/chat"] - State management via
@ai-sdk-tools/storeworks 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/devtoolslatest@ai-sdk-tools/storelatest- Using
DefaultChatTransportfromaipackage
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
Labels
No labels