Real-Time Apps with Next.js Server Actions and WebSockets in 2026
Next.jsReactFrontend

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.

HJ
Hassan Javed
May 2026
10 min read

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 targetPatternCost
~30 secPolling with revalidatePathFree
~5-10 secPolling with stale-while-revalidateFree
~1 secServer-Sent EventsLow
< 500 msWebSocketsHigher
Real-time bidirectionalWebSockets with roomsHighest

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:

Admin dashboards — stats update every 10 seconds, fine
Order tracking — status changes every minute or two, fine
Comment threads on a blog — refresh on focus plus 30 second polling, fine
Notification bell — poll every 15 seconds, fine

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:

Chat or messaging — typing indicators, instant message delivery
Collaborative editing — Figma, Notion, Google Docs style
Live game or quiz — multiplayer, leaderboards
Trading or financial UI — sub-second price updates
Live cursors — multi-user presence indication

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

Marketing pages plus dashboards: Server Actions, no WebSockets
Notifications: SSE (Server-Sent Events) — one-way, simpler than WebSockets
Chat or collab: Pusher (or Ably) for v1, plan to migrate to Soketi at scale
Real-time editing: Liveblocks (don't write CRDT yourself)

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:

1.Channel-per-resource. Don't broadcast a chat message to all users — broadcast to the channel for that conversation.
2.Presence channels only when needed. Presence tracking doubles the connection cost.
3.Throttle events. A typing indicator that fires on every keystroke is expensive. Debounce to once per second.
4.Lazy subscribe. Only subscribe when the relevant UI is visible.

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

Don't use WebSockets until you actually need sub-second updates
Server Actions plus polling covers 70 percent of "real-time" needs for free
For real WebSockets: Pusher to ship fast, Soketi to scale cheap, Cloudflare Durable Objects for greenfield edge
Watch costs: channel scoping, debouncing, lazy subscriptions

If you're building real-time features and want a senior to architect the stack, contact me.

Related Reads

You might also like