KindeK
Kinde6mo ago
1 reply
adam boukhris

Webhook decoder not working

hello guys , i installed the npm package @kinde/webhooks to decode my JWT , in the docs it says to use
const decodedWebhook = decodeWebhook("eyJhbGc..."); if (decodedWebhook.type === WebhookEventType.userCreated) { // decodedWebhook is type safe userCreated event }
the problem is i'm getting this error Property 'type' does not exist on type 'Promise<WebhookEvent | null>
and i'm getting undefined result, in my console logs :
import { Hono } from "hono";
import { decodeWebhook } from "@kinde/webhooks";

const app = new Hono();

app.post("/api/auth", async (c) => {
  const jwt = await c.req.raw.text();
  console.log("Received JWT:", jwt);

  const decoded = decodeWebhook(jwt);
  console.log("Decoded webhook type:", decoded?.type);

  if (!decoded) {
    return c.text("Invalid webhook").status(400);
  }

  if (decoded.type === "user.created") {
    console.log("Handling user.created event:", decoded.data);
    // Your logic here...
  } else {
    console.log("Received unhandled event type:", decoded.type);
  }

  return c.text("OK").status(200);
});

app.get("/", (c) => c.text("Hello Home!"));

export default app;

is the decoder not supported anymore and i should use an other one ?
Was this page helpful?