hi team, I would like to publish updated nextjs datocms starter in your starter collection (seems you have a small team, official starter has not been updated for a long time)
The one last thing is left is real time updates. Can’t understand why the connection is keep closing, although the data is received:
The error message suggests that one of your graphql queries being made with the realtime API has an error in it (it could be a syntax error, or querying a model/field that does not exist, and so on)
If you email us at support@datocms.com with your datocms project URL and the steps to reproduce the issue we can help take a look at it for you.
The issue is in your RealTime component, you’re reading process.env.NEXT_DATOCMS_READONLY_API_TOKEN directly in a client component (“use client”), but that env var simply doesn’t exist in the browser, so it’s undefined.
The subscription connects and receives the initial data (which came from the server-side fetch where the token works fine), but then fails because the client-side subscription is trying to authenticate with an undefined token.
So the issue is not that the starter is outdated, but that the way the token was passed was changed on your fork, breaking the realtime updates functionality