move auth guard to layout + convert pages to server components,cleanup#673
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
solid architectural improvement auth checks moved out of individual client pages and into the layout where they belong.
what changed
app/home/layout.tsxserver-side auth guardadded
isAuthenticatedNextjs()check at the layout level. any unauthenticated request to any/home/*route now redirects to/signupbefore rendering anything. this replaces the per-page client-sideuseConvexAuth+useEffect+router.replacepattern.app/home/page.tsx,app/home/[id]/page.tsx,app/home/[id]/[slug]/page.tsxall three converted from client components to server components. removed
useConvexAuth,useRouter,useEffect, anduseMemofrom each. they now just read params server-side and pass them down to the existing client components.app/home/[id]/[slug]/loading.tsx+NoteLoadingSkeletonUI.tsxboth updated to use
w-[900px]to match the note page content width.NoteLoadingSkeletonUIwas also rewritten with a properSkeleton+ParagraphSkeletoncomponent structure instead of the old flat div approach.app/privacy-policy/page.tsx+app/terms-of-service/page.tsxremoved the sticky footer pill from both pages it had unused imports, relied on a
scrolledstate not shown in context, and was dead ui.why
the old pattern had a flash of
nullwhile waiting for auth to resolve on the client. the layout-level server check is instant and cleaner. also makes the page files much smaller.now