How to listen changes realtime messages from Supabase Editor?
How to listen changes realtime messages from Supabase Editor?
We can do this from the Supabase dashboard for the database we created. If you haven't already, please go ahead and select for the table from its editor.Adding Realtime Collaboration
Enable RealtimeuseList()useList()useSubscriptionuseCreate()import { Refine } from "@refinedev/core";
import { liveProvider } from "@refinedev/supabase";
import { supabaseClient } from "utility";
function App() {
return (
<Refine
liveProvider={liveProvider(supabaseClient)}
options={{ liveMode: "auto" }}
/* ... other props */
>
{/* ... */}
</Refine>
);
}const { data } = useList({
resource: "yourResourceName",
// other options
});useSubscription({
channel: "resources/posts",
type: ["deleted", "updated"],
params: {
ids: ["1", "2"],
},
onLiveEvent: () => setSubscriptionCount((prev) => prev + 1),
});import { useTable, useSubscription } from "@refinedev/core";
export const PostList = () => {
const table = useTable({
meta: {
select: "*, categories(title)",
},
});
useSubscription({
channel: "categories",
types: ["*"],
onLiveEvent: () => {
table.tableQuery.refetch();
},
});
return <>{/* ... */}</>;
};