tRPC WebSocket Realtime Chat App — AI-Generated Code Prompt
CODE PREVIEW
Prompt
Create a minimal real-time chat app using tRPC with WebSocket subscriptions. Use Next.js App Router, tRPC v10, zod for validation, and a simple in-memory message store. Include a message list and input form. The UI should be clean (Tailwind CSS). Only one chat room is needed.
このデモは、tRPCとWebSocketサブスクリプションを組み合わせてリアルタイムチャットアプリを構築する方法を示しています。フロントエンドはNext.js App RouterとReact、バックエンド(非表示)はsendMessageミューテーションとonMessageサブスクリプションを公開しています。メッセージはZodで検証され、メモリに保存されます。
ポイント:splitLinkによるHTTP/WSの振り分け、useSubscriptionフック、シンプルなmutations。tRPCのリアルタイム機能を学ぶのに最適です。
Prompt Overview
This demo shows how to combine tRPC with WebSocket subscriptions to build a real-time chat application. The frontend uses Next.js App Router and React, while the backend (hidden) exposes a sendMessage mutation and an onMessage subscription. Messages are validated with Zod and stored in memory.
Key points: HTTP/WS routing via splitLink, the useSubscription hook, and simple mutations. Ideal for learning tRPC's real-time capabilities.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選