Talon Auth works with Bun's built-in HTTP server. Bun uses the standard Web platform Request/Response API, so the server code is more concise than Node.js and no extra packages are needed beyond talon-auth.
Install the package:
bun add talon-auth
Create a verifier with your app ID from the Talon dashboard:
import { createVerifier } from 'talon-auth'
const verifier = createVerifier({ appId: '[your-app-id]' })
Call verifier.verifyHeader() with the value of the Authorization header. Use req.headers.get('authorization') to read it from the Web-standard Headers object:
const { user } = await verifier.verifyHeader(req.headers.get('authorization')!)
The example below uses Bun.serve to handle requests. The index route serves an HTML page with the <talon-login> component, and the /message route verifies the JWT and returns a greeting.