Hi all, I'm using BetterAuth with a Next.js app and I'm handling incoming Twilio SMS webhooks to interact with users based on their phone number.
Previously, I used:
import { getJwtToken } from "better-auth/plugins/jwt/sign";
to create a JWT manually so I could simulate a user session when Twilio hits my webhook. But after upgrading to BetterAuth v1.3, this import no longer works.
Here’s what I’m doing:
I match the incoming From number to a user in my DB (users have a unique phone number).
I validate their role and phone verification.
Then, I was creating a session and generating a JWT token to pass to an internal LLM agent via a RuntimeContext.
Now I’m not sure what the best way is to generate that JWT in v1.3. What’s the recommended approach to simulate or generate a JWT for a known user (e.g., via their userId) for trusted backend requests like Twilio webhooks?
Appreciate any guidance!