next-sse-demo
Demo for sse-what-why-how
The demo is inspired by using-fetch-event-source-server-sent-events-react
As we all know, nextjs support stream have two ways:
- API Route under
pages
folder with edge runtime, but have some limit unsupported-apis
some issues: - Router handler under
app
folder streaming
If we connect the api to a simple nodejs service(eg: use express
), sse can be achieved with res.write
, but API router with default runtime(nodejs) not.
So why? What does nextjs do on API Routes with nodejs runtime?
refs: