"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
- Oauth issue
Hi, can anyone help me in the Oauth issue, Its working fine in dev but its showing Invalid redirect during production. I have check the redirect url and all. St...
- Google/Apple OAuth to show continue to "...
hi everyone, I am building a react-native app with expo and appwrite. I have setup an OAuth flow with Google and Apple following this doc (https://appwrite.io/b...
- Google Auth not working in a React App
Authentication with Google has failed. It redirects back to the signin route in React. Attached screenshots for configuration of Google console and Appwrite Go...