coygeek
## Summary The React Pattern in `examples/prompts/use-realtime.md` uses `await supabase.realtime.setAuth()` directly inside the synchronous callback passed to `useEffect`. The supplied JavaScript fails syntax checking before it can authenticate or subscribe. ## Steps to reproduce 1. Open the [React Pattern](https://github.com/supabase/supabase/blob/4ab54b935919ba3f4bb92f436ae4e757108e4f8a/examples/prompts/use-realtime.md#L137-L165) and copy the fenced JavaScript block into `react-example.js`. 2. Run `node --check react-example.js` with Node.js v22.23.2. No React installation, credentials, or Supabase connection is required for this parse-only check. 3. Observe the error at the `await` statement: ```text SyntaxError: await is only valid in async functions and the top level bodies of modules ``` The relevant fragment is: ```javascript useEffect(() => { // Set auth before subscribing await supabase.realtime.setAuth() }, [roomId]) ``` ## Expected behavior The documented React pattern parses as JavaScript, completes authentication before subscribing, and returns React's synchronous cleanup callback. Asynchronous setup should preserve cleanup if the component unmounts during setup. ## Actual behavior The effect callback is not async, but contains `await`. Node's syntax check rejects the exact fenced block. Simply making the effect callback async would return a Promise instead of the cleanup function React expects. ## Affected area `examples/prompts/use-realtime.md`, React Pattern, lines 142-164 at revision `4ab54b935919ba3f4bb92f436ae4e757108e4f8a`. ## Runtime or environment Node.js v22.23.2, syntax checking only. The same revision was the repository's `master` head when inspected. This report does not claim to have run a React application or contacted a Supabase project. ## Evidence - [Synchronous effect callback and invalid await](https://github.com/supabase/supabase/blob/4ab54b935919ba3f4bb92f436ae4e757108e4f8a/examples/prompts/use-realtime.md#L142-L164). - The exact published block produces the syntax error above with `node --check`. ## Impact Users copying the example and agents using this prompt receive code that cannot parse. The subscription and cleanup logic cannot run. ## Additional context The closure check is that the revised example passes syntax checking and a React verification shows authentication before subscription plus cleanup on unmount, including unmount during asynchronous setup. The report concerns this React pattern only; it is independent of the SQL examples elsewhere in the prompt.