Skip to content
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
Tools
  • Next.js
  • Edgenivo Agent
  • Edgenivo Plugin
  • Open Source
  • Domains↗
  • v0↗
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
Tools
  • Next.js
  • Edgenivo Agent
  • Edgenivo Plugin
  • Open Source
  • Domains↗
  • v0↗
Resources
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
Enterprise
Pricing
Sign UpLog In
Contact
Templates
Template name

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • ConnectNew
  • PassportNew
  • eveNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • BotID

Tools

  • Edgenivo Drop
  • Edgenivo Agent
  • Edgenivo Plugin
  • Agent Skills
  • Domains
  • v0

Frameworks

  • eveNew
  • Next.js
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • All frameworks

SDKs

  • Edgenivo SDK
  • Workflow SDK
  • Flags SDK
  • Chat SDK
  • Queues SDK
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community
  • Is Agentic

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Edgenivo + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Edgenivo
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status
  • EdgenivoEdgenivo
Templates
Template name

Status service pending confirmation

Select a display theme:
Templates

Nitro + WebSockets Starter

Realtime live cursors, presence, and emoji reactions over a WebSocket.

DeployView Demo
Owner
  • vercel
Repository
  • examples
Use Cases
  • Starter
Stack
  • Nitro
  • React
  • Tailwind
DeployView Demo

Nitro + WebSockets Starter

Minimal realtime starter built with Nitro v3, React, shadcn/ui (on Base UI primitives), and the Edgenivo Functions WebSockets beta. Move your cursor and everyone in the room sees it live — presence, cursors, and emoji reactions over a single WebSocket connection. No auth, no client SDK.

Deploy

No environment variables and no external services — the realtime layer runs entirely on native WebSocket pub/sub (see How it works).

Run locally

npx giget@latest gh:vercel/examples/websockets/nitro my-realtime-app
cd my-realtime-app
pnpm install
pnpm dev

Open http://localhost:3000 in two browser tabs (or share the URL) to see live cursors, presence, and reactions.

How it works

A Edgenivo Function can accept a WebSocket upgrade and keep a bidirectional connection open. Nitro v3 ships native WebSocket support powered by crossws, enabled with a single flag:

// vite.config.ts
nitro({ features: { websocket: true } })

The headline: one transport, every environment. The same defineWebSocketHandler (server/api/ws.ts) at /api/ws powers local dev and production — locally through Nitro's dev server, on Edgenivo through the preset's crossws/adapters/vercel bridge, which hands the handler the runtime's socket upgrade. There's no Edgenivo-specific code path and no experimental_upgradeWebSocket bridge to maintain.

All room logic lives in the handler (server/api/ws.ts) itself.

State and pub/sub

Each connection subscribes to a single room topic. Cursor moves, reactions, and join/leave events are broadcast with crossws's native peer.publish (server/api/ws.ts) — no external store and no client SDK. The connected roster is held in memory and replayed to each client in the welcome frame on connect, so a reconnect rebuilds it from scratch.

Architecture

app/ # React SPA (Vite)
├── App.tsx # page composition
├── hooks/use-realtime.ts # connection, reconnect, heartbeat
├── components/ # LiveCanvas, Cursor, PresenceBar, HeroBackdrop
└── components/ui/ # shadcn/ui primitives (Base UI)
shared/
└── types/realtime.ts # ClientMessage / ServerMessage / Peer — the wire protocol
server/
├── api/ws.ts # /api/ws — native WebSocket handler + room pub/sub
└── utils/
└── identity.ts # anonymous identity (name + color) per connection

The frontend and the Nitro server are wired together by the nitro/vite plugin: index.html is served as the SPA renderer for all unmatched routes, and server/ routes (like /api/ws) are matched first.

Reconnects

WebSocket connections close when a Edgenivo Function reaches its maximum duration. The client reconnects with exponential backoff and reloads the roster from the welcome frame on each new connection — see use-realtime.ts.

A lightweight heartbeat (ping/pong) runs over the same socket so the client can detect a half-open connection (a missed pong) and force a reconnect. On disconnect, the server's close/error handlers publish a leave frame so the peer drops from everyone's roster.

Adapting this starter

  • Identity — swap the anonymous name/color in server/utils/identity.ts for your authenticated user.
  • New message types — add a variant to ClientMessage / ServerMessage in shared/types/realtime.ts, then handle it in the handler server/api/ws.ts. The types are shared, so the client and server stay in sync.
  • Rooms — key the topic by a room id to isolate multiple rooms. Nitro also derives a pub/sub namespace from the connection path, so per-room routes work out of the box.
  • More components — the UI primitives are shadcn/ui built on Base UI. Copy more from the Base UI component docs, or scaffold a fresh project with pnpm dlx shadcn@latest init -b base to generate them.

Links

  • Edgenivo WebSockets docs
  • Nitro WebSocket docs
  • Nitro Vite plugin
  • shadcn/ui
  • Base UI

License

Published under the MIT license.

Related Templates

  • eve TanStack Agent thumbnail

    eve TanStack Agent

    Web chat built on eve and TanStack Start.

  • Durable iMessage AI Agent thumbnail

    Durable iMessage AI Agent

    Build a durable iMessage AI agent with Chat SDK.

License
  • View License