Realtime Typescript Types

Hey, how can you use Typescript in combination with realtime to get typed arguments for the callback?

const channel = supabase
    .channel("public:channelName")
    .on(
        "postgres_changes",
        {
            event: "INSERT",
            schema: "public",
            table: "channelName"
        },
        (payload) => {
            console.log("INSERT", payload);
        })
    .subscribe();


In this case payload has the type any. I did pass my Typescript definitions to the constructor when creating the SupabaseClient (const supabase = createClient<Database>) and get correct types for normal queries.
Was this page helpful?