Skip to content

Validate user tokens on the backend #845

Discussion options

You must be logged in to vote

Turns out that since Supabase uses JWTs, you can validate it as you would any other JWT.

Frontend:

supabase.auth.session()?.accessToken // gets the JWT

Backend

import { verify } from 'jsonwebtoken'

// data is the contents of the JWT if valid
const data = const verify(token, supabase_jwt_secret) // throws error if invalid

You can find the JWT secret in the Supabase dashboard. Settings > API > JWT Secret

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mariusa
Comment options

@Nick-Mazuk
Comment options

Answer selected by Nick-Mazuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants