Next.js Discord

Discord Forum

Is it possible to call an async functions inside the callback of clerkMiddleware?

Unanswered
Bald Eagle posted this in #help-forum
Open in Discord
Bald EagleOP
The following setup does not throw any errors, but the async function is not executed correctly because undefined is always returned. Is it possible to call an async functions inside the callback of clerkMiddleware?

I feel like this should be possible because NextJS allows for async middleware.

export default clerkMiddleware(async(auth, request) => {
  if (isProtectedRoute(request)) { auth().protect(); }

  await someAsyncFunction();
});

0 Replies