Next.js middleware with NextAuth server session?

What is the best way to write a Next.js middleware (middleware.ts) that redirects to /login if the user is not logged in? I'm using the t3 stack with db sessions
Was this page helpful?