Skip to content

Examples

Gerasimos (Makis) Maropoulos edited this page May 28, 2026 · 1 revision

When to use this page

  • You want a working example you can copy and run.
  • You're not sure which neffos feature to use for your problem.

All examples live at _examples/. Each is self-contained — cd into the directory and go run.

The catalog

Example What it shows
basic Minimal echo server + Go client + browser client. Start here.
example Interactive chat-style demo: connect, join a room, exchange messages, leave.
browser Vanilla browser client paired with a Go server.
native-messages Raw WebSocket frames — no neffos wire format. Useful for interop with non-neffos clients.
protobuf Binary protocol using Protocol Buffers for Message.Body.
struct-handler Methods on a Go struct used as event handlers via neffos.NewStruct.
wrap-conns-to-user Attach a user record to each Conn via Conn.Set("user", u) for auth-aware events.
cronjob Server-side scheduled tasks that broadcast over neffos.
scale-out Multi-instance neffos with Redis and NATS. Pair with [[Scale out
stress-test Synthetic load — server, client, and broadcast variants.

Running an example

git clone https://github.com/kataras/neffos
cd neffos/_examples/basic
go run echo.go server   # in one terminal
go run echo.go client   # in another

Most server examples bind to :8080. The matching browser examples have a small index.html you can open after starting the server.

JavaScript client

Browser and Node samples for the neffos.js TypeScript client live in neffos.js/_examples.

See also

Clone this wiki locally