Overview
The sync route handlers provide in-memory slide state synchronization between the presenter’s deck and the notes viewer on a phone or second screen. The presenter’s deck POSTs slide changes, and the notes viewer polls via GET to stay in sync. Important: State lives in server memory — designed fornext dev or single-server deployments. It won’t persist across serverless function invocations.
Setup
Re-export the handlers as your API route:syncEndpoint on both SlideDeck and SlideNotesView:
GET Handler
Retrieves the current slide state.Response
Returns JSON with the current slide number and total slides:Usage
TheSlideNotesView component polls this endpoint every 500ms to stay synchronized with the presenter’s deck.
POST Handler
Updates the current slide state.Request Body
Send JSON with slide number and/or total slides:slide, just total, or both.
Response
Returns the updated state:Usage
TheSlideDeck component POSTs to this endpoint whenever you navigate with keyboard (arrow keys or spacebar).
How Sync Works
- Presenter navigates →
SlideDeckPOSTs{ slide, total }to/api/nxs-sync - Notes viewer polls →
SlideNotesViewGETs from/api/nxs-syncevery 500ms - Notes update → Phone displays
notes[slide - 1]from thenotesarray
currentSlide and totalSlides variables) persists for the lifetime of the Node.js process.