Skip to content

growth(day-34): @byok-relay/tanstack — TanStack Start API route factory, server function adapter, React hooks, ByokRelayClient#70

Open
alokit-bot wants to merge 1 commit into
feat/growth-2026-07-10from
feat/growth-2026-07-11
Open

growth(day-34): @byok-relay/tanstack — TanStack Start API route factory, server function adapter, React hooks, ByokRelayClient#70
alokit-bot wants to merge 1 commit into
feat/growth-2026-07-10from
feat/growth-2026-07-11

Conversation

@alokit-bot

Copy link
Copy Markdown
Collaborator

Growth Day 34 — @byok-relay/tanstack

TanStack Start integration: API route factory, server function adapter, and React hooks for BYOK AI.

What is added

packages/tanstack/src/index.js

  • createByokRelayAPIRoute(opts) — returns a handler map for createAPIFileRoute(‘/api/relay/$’)({ ...handlers }). Reads RELAY_URL from process.env server-side only; browser only calls /api/relay. Optional app_id allowlist; 30s AbortController timeout; binary/streaming body pass-through.
  • createRelayServerFnHandler(opts) — async handler body for createServerFn().handler(fn). Receives { path, token, method, body } from Zod-validated input; returns upstream JSON or { _text, _status } for non-JSON. Timeout throws with a descriptive message.
  • useByokRelay(opts) — token registration + key CRUD + logout; localStorage default; custom storage adapter for cookie-session persistence in server functions.
  • useChat(opts) — stateful non-streaming chat; openai/anthropic/groq/mistral/openrouter; systemPrompt + extraParams; optimistic rollback on error.
  • useStreamingChat(opts) — SSE streaming with AbortController; stopStreaming() partial-commits with [stopped] suffix; streamingContent live string.
  • useRelayHealth(opts) — polls /health; check(deep?) upstream readiness; startPolling(ms) / stopPolling().
  • ByokRelayClient — plain JS class; prefers process.env.RELAY_URL on server; falls back to opts.relayUrl in browser; all relay methods + streamChat async generator + deleteAccount (GDPR). Custom storage adapter for cookie-session in Nitro server functions.

Tests — 24 smoke tests passing (node test/tanstack.test.js).

packages/tanstack/README.md — full API docs, TanStack Start quick-start (createAPIFileRoute catch-all + useStreamingChat component), server function adapter quick-start, all hooks/client documented with props/return tables, provider table, cookie-session storage example, related packages table.

llms.txt — TanStack Start Integration section (createByokRelayAPIRoute + createRelayServerFnHandler + hooks + ByokRelayClient, catch-all route + server function code snippets, npm link).

README.md — @byok-relay/tanstack section after Nuxt 3 (before ‘For AI coding agents’) with API route + useStreamingChat component examples.

metrics/daily.jsonl — 2026-07-11 snapshot (stars=52).

Key differentiator vs @byok-relay/next

TanStack Start uses createAPIFileRoute (Vinxi file-based routing) instead of Next.js app/api/relay/[...path]/route.js. The createRelayServerFnHandler adapter follows TanStack Start’s typed .handler() pattern, which is distinct from Next.js Server Actions.

Next for Avi

cd packages/tanstack && npm publish --access public

…ry, server function adapter, React hooks, ByokRelayClient
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 439d761b-a7ad-4209-8deb-d0bd7bdee159

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/growth-2026-07-11

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant