Real-Time Apps with Next.js Server Actions and WebSockets in 2026
When Server Actions are enough, when you need a WebSocket layer, and how to wire Pusher / Soketi / Ably into a Next.js 14 App Router project without breaking SSR.
The question I get every week
"Can I build a chat app or live dashboard with just Next.js Server Actions, or do I need WebSockets?"
After shipping six real-time features in the last year across client projects, the answer is: it depends on how "real-time" you actually need.
This post is the decision tree I walk new clients through, with the trade-offs that bit me.
Spectrum of "real-time"
There's a spectrum, not a binary:
| Latency target | Pattern | Cost |
|---|---|---|
| ~30 sec | Polling with revalidatePath | Free |
| ~5-10 sec | Polling with stale-while-revalidate | Free |
| ~1 sec | Server-Sent Events | Low |
| < 500 ms | WebSockets | Higher |
| Real-time bidirectional | WebSockets with rooms | Highest |
If your product can tolerate 5-second staleness (most dashboards, admin UIs, status pages), don't even reach for WebSockets. Server Actions plus revalidation gives you everything for free.
When Server Actions are enough
Server Actions in Next.js 14 App Router can mutate data and revalidate the page or specific paths. Combined with client-side polling (a 5-second interval calling a Server Action that returns fresh data), you get a "feels real-time" UX without infrastructure.
Patterns I use:
Build cost: zero new dependencies. Operational cost: zero new services. This is the ceiling for 70 percent of "real-time" requests.
When you actually need WebSockets
When the product expects sub-second feedback:
These need a persistent bidirectional channel. Polling cannot fake it.
The WebSocket options in 2026
I've used all of these on real client work:
Pusher and Ably
Cost: Free tier handles around 200 concurrent. Paid starts ~50 dollars per month.
Pros: Drop-in, hosted, presence and history built-in, mature SDKs.
Cons: Vendor lock-in, costs scale with traffic.
Use when: You want to ship in a day and pay for it later.
Soketi (self-hosted Pusher-compatible)
Cost: Free plus your server.
Pros: Pusher API, but self-hosted. Cheap at scale.
Cons: You operate it.
Use when: You've outgrown Pusher's pricing and have ops capacity.
Socket.IO with a separate Node server
Cost: Server cost only.
Pros: Maximum control, rooms, namespaces, fallbacks.
Cons: You operate it, edge deployment is harder.
Use when: You need custom server-side logic in real time.
Cloudflare Durable Objects
Cost: Pay per request, scales to zero.
Pros: Edge-native, no server to operate, perfect for multiplayer.
Cons: New mental model, Cloudflare lock-in.
Use when: Greenfield project with multiplayer needs.
Liveblocks
Cost: Free tier, paid at scale.
Pros: Built specifically for collaboration features (cursors, presence, CRDT).
Cons: Specific to collaboration use cases.
Use when: You're building collab features and don't want to write CRDT logic.
My default stack for SaaS in 2026
The Next.js App Router gotcha
WebSocket connections don't work natively in serverless functions (Vercel, Netlify). You need either a managed WebSocket service (Pusher, Ably) called from your Next.js client, a separate WebSocket server on a long-running host (Railway, Render, Fly), or Cloudflare Workers with Durable Objects.
I default to managed services for almost everything. Fewer moving parts.
Cost discipline
Pusher and Ably bills can creep up fast if you broadcast to all connections constantly. Patterns to keep costs sane:
These four patterns cut one client's Pusher bill from 400 dollars per month to 85 dollars per month with the same functional behavior.
TL;DR
If you're building real-time features and want a senior to architect the stack, contact me.
You might also like
React Server Components in Next.js 14: Production Patterns That Work
When to use Server Components vs Client Components in Next.js 14, the patterns that survive production, and the foot-guns I keep tripping over after shipping 8+ App Router projects.
Next.js App Router vs Pages Router: Lessons From 12 Project Migrations
What changes, what breaks, what to migrate first, and what to leave alone. Hard-earned migration lessons from moving 12 client projects from Pages Router to App Router.
TypeScript Generics for React Engineers: A Practical Guide
The 6 generic patterns I use weekly on React + Next.js codebases — typed hooks, polymorphic components, discriminated unions, infer, constraints — without the academic noise.