Skip to content
Back

How do i connect to realtime? I dont get any updates.

  • 0
  • Databases
  • Web
  • Realtime
PreskU
24 Feb, 2026, 00:21

I am trying to connect to realtime database updates but don't seem to receive any updates. Documentation is pretty bad and i am stuck. Can anyone help? Here is what i am trying with, maybe i am stupid:

TypeScript
  useEffect(() => {
    loadElements();

    if (!projectData) return;

    let subscription;

    const setupRealtime = async () => {
      const subscription = await realtime.subscribe(Channel.tablesdb(), response => {
        if (response.events.includes('databases.*.elements.*.update')) {
          console.log(response.payload);
        }
      });
    }
    setupRealtime();
  }, [projectData]);
TL;DR
Developers having trouble receiving updates from their realtime database while using the code snippet provided. They suspect the issue may be due to poor documentation. Here's a suggested solution: The issue in the code is that a new variable `subscription` is being defined within the `setupRealtime` function instead of updating the one declared outside. To fix this, remove the `let` before `subscription` in `setupRealtime` function. This way, it will update the outer variable properly and receive updates from the realtime database.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more