Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed auth architecture for clerk #2739

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MiltonAkash
Copy link

@MiltonAkash MiltonAkash commented Nov 12, 2024

Current architecture using beforeLoad fetched auth on every route change making lag on navigation resulting bad UX

@EugenEistrach
Copy link

EugenEistrach commented Nov 12, 2024

Hi, this PR does have some issues.
For example the main purpose of the _authed.tsx layout is to protect all child routes from being accessed when not authenticated. This change would break that behaviour.

Im not sure but I dont think navigations should cause big performance issues as clerk should store auth info in session which should be fast. Atleast that was the case with the nextjs implementation. So maybe your performance issues do have other root cause.

For reference here are the clerk tanstack start docs: https://clerk.com/docs/references/tanstack-start/get-auth

@MiltonAkash
Copy link
Author

@EugenEistrach The state of the auth can be obtained through clerk given useAuth which makes call only once per session and on authstate change. But the approach of calling a server fn in the _root loader makes it call on every route change. This makes navigation sick. Clerk Prod instance with app deployed on vercel makes 400ms to resolve this and page feels unresponsive during this time.

I'm trying tanstack-start on production(even though it is not recommended) and this sluggish feel is a problem.

I'm don't have much understanding with tanstack router. So correct me if I'm wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants