Skip to content
Back

Auth Error

  • 0
  • Auth
  • Web
  • Cloud
Popt
1 May, 2025, 15:19

"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();

TypeScript
  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.

TL;DR
Developers encountering an authentication error while trying to enable real-time data retrieval. They need to ensure that permissions for accessing collections are properly configured. The provided code snippet utilizes Next.js with a function handling real-time data subscription based on user permissions.
Kenny
1 May, 2025, 15:44

What is the exact error you get.

Kenny
1 May, 2025, 15:45

You also don't have to set permissions to any for people to get realtime data. Realtime works based on user permissions.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more