Calculate the number of seconds until a JWT expires.
The decoded JWT payload.
Current time in seconds since epoch.
Seconds remaining, or Infinity if there is no exp claim. A negative value means the token is already expired.
Infinity
exp
const remaining = secondsUntilExpiry(jwt.payload);if (remaining < 300) { // less than 5 minutes — trigger silent refresh} Copy
const remaining = secondsUntilExpiry(jwt.payload);if (remaining < 300) { // less than 5 minutes — trigger silent refresh}
Calculate the number of seconds until a JWT expires.