Is there a cheaper option than useSWR built into Next? #4111
Unanswered
easy-thunder
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, so this is how I have implemented useSWR in the past:
const { data, error } = useSWR(gameIdRef.current ?
/api/games/connectFour?gameId=${gameIdRef.current}
: null, fetcher, {refreshInterval: 1000,
});
Basically polling my server every second for changes on a turn based game.
I did this for a school project and haven't deployed it because I'm worried that this might cause high costs if this game becomes popular. For example if I had an average of 10 players online all the time I estimate that would be 26 million requests a month.
I'm considering using PeerJS because most of what is paid is the initial handshake(or I believe please tell me if I'm wrong). But I'm pretty familiar and comfortable with Next.js and am curious if there are other options that could reduce cost.
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions