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
Shashank6mo 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
Shashank6mo 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

Did you find this page helpful?