-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Love the package! Once I got it working, it's a very clean way of doing SSE.
I followed your example for NextJS with the App Router and found that it didn't work as the state I wanted persisted (namely, the Channel) wasn't being kept around. I'm not sure how NextJS works internally, so I have to assume this is expected (though not expected to a newbie) behavior.
I got around it with:
let channel: Channel;
// This fixes the issue of channel being reset on every request. I don't
// know how to do this more reasonably.
// https://github.com/vercel/next.js/discussions/48427#discussioncomment-10550280
if (process.env.NODE_ENV === "production") {
channel = new Channel();
} else {
// @ts-ignore
if (!(global).channel) {
// @ts-ignore
global.channel = new Channel();
}
// @ts-ignore
channel = global.channel;
}Is this a known issue/pattern? Should this be documented in the examples, or is there a cleaner way around this on my side?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels