Now Live: WebSockets & QR Codes

PatChat

Experience premium real-time messaging powered natively by Vercel WebSockets, Neon serverless Postgres, and Clerk Authentication.

Interactive Chat Simulator

User Profile & Connect

System Status

WebSocket NodeONLINE
Neon DatabaseCONNECTED
Mock Latency12ms
Active Clients142 sessions

Vercel WebSockets in Next.js

Upgrade API routes to real-time serverless WebSocket channels using Vercel Fluid Compute.

// src/app/api/ws/route.ts
import { experimental_upgradeWebSocket } from "@vercel/functions";
import { connection } from "next/server";

export async function GET() {
  await connection();
  
  return experimental_upgradeWebSocket((ws) => {
    ws.on("message", (data) => {
      // Handle bidirectional events (join, send-message, typing, etc.)
      ws.send(JSON.stringify({ type: "message", text: "Echo: " + data }));
    });
    
    ws.on("close", () => console.log("WebSocket connection closed"));
  });
}
*Powered by experimental_upgradeWebSocket from @vercel/functions.