Back

Fetch Data in real time.

  • 1
  • Databases
  • Web
  • Realtime
AbdullahSidd
28 May, 2023, 12:54

Hey I am fetching all the documents from appwrite database but the problem is that i want to fetch them in a real time. For example if a user post then that post visible in ui only after i refresh the page. So I want to see the real time update in ui. So how can I fetch data in real time like snapshot in firebase ?

TL;DR
The user wants to fetch data in real time, similar to Firebase's snapshot feature. They are using Next.js and want to know how to implement this with Appwrite. A solution is provided, which involves subscribing to the appropriate event using Appwrite's Realtime feature. The user is also directed to the documentation for more information.
conqueror
28 May, 2023, 13:11
AbdullahSidd
28 May, 2023, 13:13

@conqueror I don't find such function in docs. can you give me the reference to that function that fetch data in real time ?

conqueror
28 May, 2023, 13:15

which function you are talking about

conqueror
28 May, 2023, 13:16

are you using flutter ?

AbdullahSidd
28 May, 2023, 13:17

That's help me to fetch data in real time like snapshot in firebase. I am using nextjs.

safwan
28 May, 2023, 13:19

You can use Appwrite's Realtime feature for this.

As mentioned by @conqueror

safwan
28 May, 2023, 13:20

You can subscribe to the databases.*.collections.*.documents.*.create event. This will send you the data of the created document, as soon as it is created.

safwan
28 May, 2023, 13:21

All possible events are listed here: https://appwrite.io/docs/events

AbdullahSidd
28 May, 2023, 13:22

Should I have to use listdocument method to fetch ?

safwan
28 May, 2023, 13:22

Please go through the docs for Realtime, and you'll know what to do 😄

conqueror
28 May, 2023, 13:22

if you want more then one then go for it

conqueror
28 May, 2023, 13:23

just use this and you are good to go ```import { Client } from "appwrite";

const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') .setProject('[PROJECT_ID]');

// Subscribe to files channel client.subscribe('files', response => { if(response.events.includes('buckets..files..create')) { // Log when a new file is uploaded console.log(response.payload); } });```

safwan
28 May, 2023, 13:27

@conqueror, please don't cross-post questions in other threads. It's best to wait.

conqueror
28 May, 2023, 13:27

ok

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