© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
S
Supabase
•
3mo ago
•
57 replies
ZenoAssist
Realtime not working with Custom Jwt with RLS
realtime
RLS
If i enable my RLS
, i am able to do normal fetching from a custom JWT
, which means RLS is working
. But
, real
-time subscription is not working
, and i am not able to fetch anything from the table
. This issue is kinda similar to
-
https://stackoverflow.com/questions/79583118/supabase-realtime-subscription-not-working-with-custom-jwt-and-rls-in-next-js
i even tried implementing what
's there on StackOverflow comment
, but still not working
. Code for reference
:
const now
= Math
.floor
(Date
.now
(
)
/ 1000
)
;
/
/ current time in seconds
async function createJwt
(payload
)
{
const header
=
{
alg
:
"HS256
"
,
typ
:
"JWT
"
}
;
const encodedHeader
= base64UrlEncode
(JSON
.stringify
(header
)
)
;
const encodedPayload
= base64UrlEncode
(JSON
.stringify
(payload
)
)
;
const data
=
${encodedHeader}.${encodedPayload}
${encodedHeader}.${encodedPayload}
;
/
/ SIGN WITH
JWT SECRET
const key
= await crypto
.subtle
.importKey
(
"raw
"
, new TextEncoder
(
)
.encode
(JWT
_SECRET
)
,
{
name
:
"HMAC
"
,
hash
:
"SHA
-256
"
}
, false
,
[
"sign
"
]
)
;
const signature
= await crypto
.subtle
.sign
(
"HMAC
"
, key
, new TextEncoder
(
)
.encode
(data
)
)
;
const encodedSig
= base64UrlEncode
(new Uint8Array
(signature
)
)
;
return
${data}.${encodedSig}
${data}.${encodedSig}
;
}
const exp
= now
+ 30
* 24
* 60
* 60
;
/
/ 30 days in seconds
const token
= await createJwt
(
{
sub
: unique
_id
,
unique
_id
: unique
_id
,
role
:
"authenticated
"
,
exp
}
)
;
Supabase
Join
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Next page
Similar Threads
Realtime not working with RLS
S
Supabase / help-and-questions
4y ago
Realtime with custom JWT not working on Supabase platform
S
Supabase / help-and-questions
4y ago
Realtime RLS not working with anon user
S
Supabase / help-and-questions
3y ago
(solved) Realtime subscriptions not working with RLS?
S
Supabase / help-and-questions
4y ago