authenticationnext.jsoauthnext.js13clerk

Next.js with Clerk Auth - how to detect if a user just signed up?


Using Clerk Auth, I have a working login/sign-up flow with Next.js 13 middleware.

When a user signs up, I want to add a row to my DB's Users table.

The problem with middleware is that it runs on every single request and I don't want to make a call to my database to check if the user exists so I can create a record.

Does Clerk return any data that I can use to differentiate a sign-up vs a normal request?


Solution

  • I think you might need to create webhooks that listen to user.created. See