© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3mo ago•
57 replies
ZenoAssist

Realtime not working with Custom Jwt with RLS

realtimeRLS
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 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
Next page

Similar Threads

Realtime not working with RLS
SupabaseSSupabase / help-and-questions
4y ago
Realtime with custom JWT not working on Supabase platform
SupabaseSSupabase / help-and-questions
4y ago
Realtime RLS not working with anon user
SupabaseSSupabase / help-and-questions
3y ago
(solved) Realtime subscriptions not working with RLS?
SupabaseSSupabase / help-and-questions
4y ago