Skip to content

Is there a way to create JWT like with jsonwebtoken #1468

Discussion options

You must be logged in to vote

Hono has a JWT util. As of 3.7.0, this can be used like:

import * as Jwt from 'hono/jwt'

const token = await Jwt.sign(
    {
      sub: "SESSION_ID",
      jti: "TOKEN_ID",
      iat: Math.floor(Date.now() / 1000),
      exp: Math.floor(Date.now() / 1000) + expiresIn,
      iss: "ISSUER",
      aud: "AUDIENCE",
    },
    env.JWT_SECRET,
  );

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@azimari-toure-ikbal
Comment options

Answer selected by azimari-toure-ikbal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants