Tanstack Router and Clerk
I have a React SPA web application with Tanstack Router (file-based routing) and I want to protect the whole app - except the login route I guess - using Clerk (I will later also protect my Hono backend's endpoints but that's for later). Considering Clerk is a partner of Tanstack, I was hoping I could find some "official" examples on how to do this properly, but unfortunately the only resources I could find were for Tanstack Start, and a few old repos with completely different approaches.
I would really appreciate if anyone could explain or show me how to do it properly once and for all, so I can use it in all my apps, knowing it most likely follows best practices, is secure, doesn't slow down my app unnecessarily (big concern), etc.
Thank you 🙂
2 Replies
genetic-orange•3mo ago
cc @wobsoriano
ambitious-aqua•3mo ago
Hi there! For tanstack router apps, I prefer using the
@clerk/clerk-react
package. Here's the example I usually give when someone requests tanstack router + clerk https://github.com/wobsoriano/tanstack-router-clerkGitHub
GitHub - wobsoriano/tanstack-router-clerk
Contribute to wobsoriano/tanstack-router-clerk development by creating an account on GitHub.