© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
Teiem

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();
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
payload
has the type
any
any
. I did pass my Typescript definitions to the constructor when creating the
SupabaseClient
SupabaseClient
(
const supabase = createClient<Database>
const supabase = createClient<Database>
) and get correct types for normal queries.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Typescript types for views always nullable?
SupabaseSSupabase / help-and-questions
4y ago
npx supabase gen types typescript broke
SupabaseSSupabase / help-and-questions
4mo ago
Generating TypeScript types for remote database
SupabaseSSupabase / help-and-questions
4y ago
realtime
SupabaseSSupabase / help-and-questions
6mo ago