Problems with before/after hooks

Hi I'm having trouble using the hooks with better-auth :
export const auth = betterAuth({
  socialProviders: {
    discord: {
      clientId: process.env.AUTH_DISCORD_ID!,
      clientSecret: process.env.AUTH_DISCORD_SECRET!,
      prompt: "consent",
      redirectURI: `${process.env.BETTER_AUTH_URL}/api/auth/callback/discord`,
    },
  },

  hooks: {
    before: createAuthMiddleware(async (ctx) => {
      console.log("before");
    }),
    after: createAuthMiddleware(async (ctx) => {
      console.log("after;");
    }),
  },

  session: {
    freshAge: 7 * 24 * 3600, // 7 days
  },
});
None of the events are fired. Thanks !
Was this page helpful?