Gathering detailed insights and metrics for @supabase/realtime-js
Gathering detailed insights and metrics for @supabase/realtime-js
Gathering detailed insights and metrics for @supabase/realtime-js
Gathering detailed insights and metrics for @supabase/realtime-js
@kanli8_supabase/realtime-js
Listen to realtime updates to your PostgreSQL database
nestjs-supabase-js
NestJS Supabase integration
supabase-js-without-realtime-js
Isomorphic Javascript client for Supabase without Realtime js
@selfdb/js-sdk
Official JavaScript/TypeScript SDK for SelfDB - a self-hosted alternative to Supabase
An isomorphic Javascript client for Supabase Realtime server.
npm install @supabase/realtime-js
Typescript
Module System
Node Version
NPM Version
97.9
Supply Chain
99.1
Quality
98.4
Maintenance
100
Vulnerability
100
License
TypeScript (96.59%)
JavaScript (2.9%)
CSS (0.51%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
366 Stars
353 Commits
74 Forks
32 Watchers
13 Branches
124 Contributors
Updated on Jul 01, 2025
Minified
Minified + Gzipped
Latest Version
2.11.15
Package Id
@supabase/realtime-js@2.11.15
Unpacked Size
384.91 kB
Size
55.84 kB
File Count
93
NPM Version
10.8.2
Node Version
18.20.8
Published on
Jun 25, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Guides · Reference Docs · Multiplayer Demo
This client enables you to use the following Supabase Realtime's features:
1npm install @supabase/realtime-js
1import { RealtimeClient } from '@supabase/realtime-js' 2 3const client = new RealtimeClient(REALTIME_URL, { 4 params: { 5 apikey: API_KEY 6 }, 7}) 8 9const channel = client.channel('test-channel', {}) 10 11channel.subscribe((status, err) => { 12 if (status === 'SUBSCRIBED') { 13 console.log('Connected!') 14 } 15 16 if (status === 'CHANNEL_ERROR') { 17 console.log(`There was an error subscribing to channel: ${err.message}`) 18 } 19 20 if (status === 'TIMED_OUT') { 21 console.log('Realtime server did not respond in time.') 22 } 23 24 if (status === 'CLOSED') { 25 console.log('Realtime channel was unexpectedly closed.') 26 } 27})
REALTIME_URL
is 'ws://localhost:4000/socket'
when developing locally and 'wss://<project_ref>.supabase.co/realtime/v1'
when connecting to your Supabase project.API_KEY
is a JWT whose claims must contain exp
and role
(existing database role).string
.Your client can send and receive messages based on the event
.
1// Setup... 2 3const channel = client.channel('broadcast-test', { broadcast: { ack: false, self: false } }) 4 5channel.on('broadcast', { event: 'some-event' }, (payload) => 6 console.log(payload) 7) 8 9channel.subscribe(async (status) => { 10 if (status === 'SUBSCRIBED') { 11 // Send message to other clients listening to 'broadcast-test' channel 12 await channel.send({ 13 type: 'broadcast', 14 event: 'some-event', 15 payload: { hello: 'world' }, 16 }) 17 } 18})
ack
to true
means that the channel.send
promise will resolve once server replies with acknowledgement that it received the broadcast message request.self
to true
means that the client will receive the broadcast message it sent out.private
to true
means that the client will use RLS to determine if the user can connect or not to a given channel.Your client can track and sync state that's stored in the channel.
1// Setup... 2 3const channel = client.channel( 4 'presence-test', 5 { 6 config: { 7 presence: { 8 key: '' 9 } 10 } 11 } 12) 13 14channel.on('presence', { event: 'sync' }, () => { 15 console.log('Online users: ', channel.presenceState()) 16}) 17 18channel.on('presence', { event: 'join' }, ({ newPresences }) => { 19 console.log('New users have joined: ', newPresences) 20}) 21 22channel.on('presence', { event: 'leave' }, ({ leftPresences }) => { 23 console.log('Users have left: ', leftPresences) 24}) 25 26channel.subscribe(async (status) => { 27 if (status === 'SUBSCRIBED') { 28 const status = await channel.track({ 'user_id': 1 }) 29 console.log(status) 30 } 31})
Receive database changes on the client.
1// Setup... 2 3const channel = client.channel('db-changes') 4 5channel.on('postgres_changes', { event: '*', schema: 'public' }, (payload) => { 6 console.log('All changes in public schema: ', payload) 7}) 8 9channel.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'messages' }, (payload) => { 10 console.log('All inserts in messages table: ', payload) 11}) 12 13channel.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'users', filter: 'username=eq.Realtime' }, (payload) => { 14 console.log('All updates on users table when username is Realtime: ', payload) 15}) 16 17channel.subscribe(async (status) => { 18 if (status === 'SUBSCRIBED') { 19 console.log('Ready to receive database changes!') 20 } 21})
You can see all the channels that your client has instantiatied.
1// Setup... 2 3client.getChannels()
It is highly recommended that you clean up your channels after you're done with them.
1// Setup... 2 3const channel = client.channel('some-channel-to-remove') 4 5channel.subscribe() 6 7client.removeChannel(channel)
1// Setup... 2 3const channel1 = client.channel('a-channel-to-remove') 4const channel2 = client.channel('another-channel-to-remove') 5 6channel1.subscribe() 7channel2.subscribe() 8 9client.removeAllChannels()
This repo draws heavily from phoenix-js.
MIT.
No vulnerabilities found.
Reason
15 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More