Backend
Integrate Hanko with Bun backend
Add the Hanko API URL
Retrieve the API URL from the Hanko console and place it in your .env file.
.env
If you are self-hosting Hanko you need to provide your own URL.
Hanko Authentication with JWT
Upon a successful login, Hanko sends a cookie containing a JSON Web Token (JWT). You can use this JWT to authenticate requests on your backend.
Steps to Authenticate Requests
-
Retrieve the JSON Web Key Set (JWKS): The JWKS has the public keys to verify the JWT. Fetch it from the Hanko API’s
.well-known/jwks.json
endpoint. -
Verify the JWT: Use the JWKS obtained to verify the JWT.
Bun-based Backend Examples
In the following examples, we demonstrate how to implement a custom middleware in Hono.js and Elysia.js backend using jose library.