STOP using Layouts for Authentication!
Guys guys! I am current using:
- Clerk + Convex
To manage my user session and I stepped on this video:
https://www.youtube.com/watch?v=EGDD0rlBd8Q&list=PLQUI8MOWevxfzVAhNMCHWraRgpXFha-uQ&index=20
What you guys are doing to solve this? How do you guys protect your private routes?
Jolly Coding
YouTube
STOP using Layouts for Authentication!
Layouts combined with Server Components are awesome, and allow us to make database calls right from out components. However, there is a common pitfall with them when it comes to how we think of their rendering order. This is critical if you are trying to hide specific content using a layout check, as you may find the content can still be exposed...
3 Replies
I'm using custom functions from
convex-helpers
to authenticate all of my public Convex functions: https://stack.convex.dev/custom-functionsCustomizing serverless functions without middleware
Re-use code and centralize request handler definitions with discoverability and type safety and without the indirection of middleware or nesting of wr...
how does that work? Can you give me a hand with that?
I need something a sort of "middleware" that authenticates all my routes in nextjs app router
If you're trying to authenticate your Next.js routes, the Stack article I linked might not be what you're looking for actually. But it looks like Clerk has some middleware for Next.js that could work: https://clerk.com/docs/references/nextjs/clerk-middleware
Next.js: clerkMiddleware()
The
clerkMiddleware()
function allows you to protect your Next.js application using Middleware.