"use client";
import { useEffect } from "react"; import { getSessionCookie } from "@/actions/auth"; import { createBrowserSessionClient } from "@/lib/appwrite-browser";
export default function Orders() { useEffect(() => { const startRealtime = async () => { const session = await getSessionCookie();
if (!session) return;
const { client } = createBrowserSessionClient(session);
const unsubscribe = client.subscribe(
`databases.${process.env
.NEXT_PUBLIC_APPWRITE_DATABASE!}.collections.${process.env
.NEXT_PUBLIC_APPWRITE_COLLECTION_ORDERS!}.documents`,
(response) => {
console.log(response);
}
);
return () => {
unsubscribe();
};
};
startRealtime();
}, []);
return <div></div>; }
Dev stack: Next.js I now need to set the collections permissions to anyone who can access them in order to receive real time. I am sure that the session I passed in is correct.
What is the exact error you get.
You also don't have to set permissions to any for people to get realtime data. Realtime works based on user permissions.
Recommended threads
- All My Project is Gone
Hello everyone, please help. Why have all my projects suddenly disappeared? I received a warning via email about one of my projects being paused. When I clicked...
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...