Neon can use client component, but not local postgres? - next14,postgres,drizzle -

Hi, how to re-create this use-effect using a server component? useEffect(() => { const fetchNotifications = async () => { if (email) { const user = await getUserByEmail(email); if (user) { const unreadNotifications = await getUnreadNotifications(user.id); setNotifications(unreadNotifications); } } }; fetchNotifications(); const notificationInterval = setInterval(fetchNotifications, 30000); // Poll every 30 seconds return () => clearInterval(notificationInterval); }, [email]); thanks.
4 Replies
Shashank
Shashank2mo ago
well you can place fetchNotifications in a server action or server-only file to do it in server component server actions are the right way considering you will need email from client side in a form
ディープブルー (deepblue)
was thinking also to refetch or revalidate. like cache in react-query or knocklabs
Shashank
Shashank2mo ago
If you revalidate a page it will update for all the users who visit that page. Either make page url unique for users or use tags
Want results from more Discord servers?
Add your server