Skip to main content
React apps usually need three pieces at once:
  • a local route that starts or adopts the camera server
  • a lifecycle layer that handles polling + SSE + reconnect
  • component state that renders camera/session data cleanly
The real TypeScript example app in this repo does not hide all of that behind one giant library call. It keeps the moving pieces explicit in:
  • example_app/src/app/api/server/route.ts
  • example_app/src/lib/event-stream.ts
  • example_app/src/lib/camera-manager.ts
  • example_app/src/app/page.tsx
This recipe shows the same pattern as a reusable hook.

When to use

  • Next.js / React apps that want to embed the server lifecycle
  • Apps that should auto-discover and auto-connect cameras
  • Apps that want typed action helpers without owning raw SSE parsing everywhere

When NOT to use

  • Scripts or CLIs — call the SDK client directly
  • Non-React apps — use the discovery/SSE recipes directly

Hook pattern

Usage

Why this matches the real app

  • The browser layer starts the server through POST /api/server, not by spawning a binary directly in client code.
  • CameraManager owns polling, SSE, connect timing, reconnect, and post-connect setup.
  • React components stay focused on state + rendering, not transport details.
That is the same boundary the repo’s actual Next.js example uses.