Using firestore onSnapshot with nextjs for realtime updates

  Kiến thức lập trình

I want to fetch user data from firestore using onSnapshot based on cookies session id and display info about this user on web with realtime changes. But if i try to use this snapshot data in useEffect it throws a error cause useEffect is only available in client components and cookies().get() is making it a server component.

I read all the docs about fetching data and realtime updates using onSnapshot. I tried to use caching from nextjs but i don’t know how to make it work with firestore onSnapshot

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT