[Docs][site] - Add signin functionality#876
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a new handler route wiring StackHandler to stackServerApp, introduces a global loading UI, updates layout/header to include UserButton across desktop/mobile, refactors compact navbar structure, configures Stack Auth via env-backed options, adjusts a demo to use real user via useUser, and updates docs to reference UserButton. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant N as Next.js Route /handler/[...stack]
participant SH as StackHandler
participant SA as stackServerApp
participant Auth as Stack Auth Backend
U->>N: HTTP request (stack route)
N->>SH: Render with fullPage, routeProps
SH->>SA: Dispatch request
SA->>Auth: Validate tokens / resolve session
Auth-->>SA: Auth result
SA-->>SH: Response payload
SH-->>N: Rendered output
N-->>U: HTTP response
note over SA,Auth: SA configured via env: projectId, keys, baseUrl
sequenceDiagram
autonumber
participant V as Viewer
participant Demo as stack-user-button-demo
participant Hook as useUser()
participant UB as UserButton
V->>Demo: Open demo
Demo->>Hook: Get current user
Hook-->>Demo: user | null
alt user exists
Demo->>UB: Render with mockUser = undefined
Demo-->>V: Status: "Using your actual account"
else no user
Demo->>UB: Render with mockUser object
Demo-->>V: Status: "Using mock data (sign in...)"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Greptile Summary
This PR integrates Stack Auth authentication into the documentation site, enabling users to sign in to the docs. The implementation adds authentication handlers, user interface components, and configuration updates across the docs application.
The main changes include:
Authentication Infrastructure: A new authentication handler (docs/src/app/handler/[...stack]/page.tsx) is added following Next.js App Router conventions for dynamic routes. This handler wraps the StackHandler component with fullPage mode enabled, providing the necessary endpoint for Stack Auth to function.
Stack Configuration: The docs/src/stack.ts file is updated to include proper environment variables (projectId, publishableClientKey, secretServerKey, baseUrl) required for Stack Auth functionality. The layout component is updated to use a cleaner import path (@/stack instead of ../stack).
User Interface Integration: UserButton components are strategically placed throughout the documentation interface, including the home layout, shared header (both desktop and mobile versions), and various navigation contexts. This provides consistent access to authentication features regardless of user location in the docs.
Enhanced Demo Component: The existing UserButton demo component is enhanced to work with real authentication state, conditionally showing actual user data when signed in while maintaining mock data fallback for unauthenticated users.
Supporting Elements: A loading component is added for authentication state transitions, and CSS fixes ensure proper z-index layering for dropdown menus.
The implementation follows patterns established in other parts of the Stack Auth codebase, particularly the dashboard and examples directories, but is simplified for the documentation context.
PR Description Notes:
- Minor grammatical issue: "signin" should be "sign-in" for consistency
Confidence score: 3/5
- This PR introduces authentication functionality with some implementation concerns that need attention
- Score lowered due to potential runtime issues from missing environment variable validation and a documentation typo
- Pay close attention to
docs/src/stack.tsanddocs/templates/components/user-button.mdx
9 files reviewed, 1 comment
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (6)
docs/src/app/loading.tsx (1)
1-7: Add basic a11y semantics to the loading UIExpose the loading state to assistive tech.
Apply this diff:
export default function Loading() { return ( - <div> - Loading... - </div> + <div role="status" aria-live="polite" aria-busy="true"> + Loading... + </div> ); }docs/src/app/handler/[...stack]/page.tsx (1)
1-6: Handler wiring matches examples; consider explicit typing/dynamic hint.
- Typing: if the SDK exports a route-props type, prefer it over
unknownfor DX.- Next caching: handler routes often rely on cookies/headers; consider forcing dynamic to avoid accidental static optimization.
Apply if desired:
+// Optional: ensure no static optimization for the auth handler +export const dynamic = 'force-dynamic'; + -import { stackServerApp } from '@/stack'; +import { stackServerApp } from '@/stack'; import { StackHandler } from '@stackframe/stack'; -export default function Handler(props: unknown) { +// If available: import { StackRouteProps } from '@stackframe/stack' +// export default function Handler(props: StackRouteProps) { +export default function Handler(props: any) { return <StackHandler fullPage app={stackServerApp} routeProps={props} />; }Confirm whether the SDK recommends
dynamic = 'force-dynamic'for this route in its docs.docs/src/components/stack-auth/stack-user-button-demo.tsx (2)
21-23: Handle transient undefined/null user states explicitly (minor).
useUser()may be briefly undefined/null during hydration. Your truthy check works; if you want stricter intent, useuser != null.- {user ? ( + {user != null ? (
116-124: Announce status changes to assistive tech.Make the live account/mock status screen-reader friendly.
- <div className="text-xs text-fd-muted-foreground"> + <div className="text-xs text-fd-muted-foreground" role="status" aria-live="polite">docs/src/components/layouts/home-layout.tsx (2)
143-145: Add an accessible label if the library doesn’t provide one.If
UserButtonrenders only an avatar without visible text, confirm it includes an internalaria-label(e.g., “Account”). If not, pass a prop or wrap with a labeled button for a11y.
196-258: Compact navbar additions look good; minor a11y polish.
- Consider
aria-labelon the GitHub/Discord icon links (desktop compact view relies on icon-only).- If the library supports a compact/small variant of
UserButton, use it here for visual consistency.- <Link ... title="GitHub"> + <Link ... title="GitHub" aria-label="GitHub"> <Github className="h-4 w-4" /> </Link> - <Link ... title="Discord"> + <Link ... title="Discord" aria-label="Discord"> <DiscordIcon className="h-4 w-4" /> </Link>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
docs/src/app/global.css(1 hunks)docs/src/app/handler/[...stack]/page.tsx(1 hunks)docs/src/app/layout.tsx(1 hunks)docs/src/app/loading.tsx(1 hunks)docs/src/components/layouts/home-layout.tsx(6 hunks)docs/src/components/layouts/shared-header.tsx(3 hunks)docs/src/components/stack-auth/stack-user-button-demo.tsx(4 hunks)docs/src/stack.ts(1 hunks)docs/templates/components/user-button.mdx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Prefer ES6 Map over Record when representing key–value collections
Files:
docs/src/app/loading.tsxdocs/src/app/layout.tsxdocs/src/stack.tsdocs/src/app/handler/[...stack]/page.tsxdocs/src/components/layouts/shared-header.tsxdocs/src/components/stack-auth/stack-user-button-demo.tsxdocs/src/components/layouts/home-layout.tsx
🧬 Code graph analysis (2)
docs/src/app/handler/[...stack]/page.tsx (7)
examples/docs-examples/src/app/handler/[...stack]/page.tsx (1)
Handler(4-6)examples/e-commerce/src/app/handler/[...stack]/page.tsx (1)
Handler(4-6)examples/supabase/app/handler/[...stack]/page.tsx (1)
Handler(4-6)examples/demo/src/app/handler/[...stack]/page.tsx (1)
Handler(4-8)examples/cjs-test/app/handler/[...stack]/page.jsx (1)
Handler(4-6)examples/partial-prerendering/src/app/handler/[...stack]/page.tsx (1)
Handler(4-10)examples/middleware/src/app/handler/[...stack]/page.tsx (1)
Handler(4-10)
docs/src/components/layouts/home-layout.tsx (1)
docs/src/components/layout/theme-toggle.tsx (1)
ThemeToggle(26-111)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build (22.x)
- GitHub Check: build (22.x)
- GitHub Check: restart-dev-and-test
- GitHub Check: lint_and_build (latest)
- GitHub Check: all-good
- GitHub Check: setup-tests
- GitHub Check: docker
- GitHub Check: docker
- GitHub Check: Security Check
🔇 Additional comments (7)
docs/src/components/layouts/shared-header.tsx (1)
6-6: LGTM: importing UserButtonImport path and symbol look correct.
docs/src/app/layout.tsx (1)
1-1: Alias import verified; no client-side imports
- docs/tsconfig.json defines baseUrl = "." and maps "@/" → "./src/", so "@/stack" resolves to docs/src/stack.ts
- No files under docs/src/** with a
"use client"directive import from"@/stack"—server-only usage confirmeddocs/src/components/stack-auth/stack-user-button-demo.tsx (3)
3-3: Good: real user state viauseUser.Hooking the demo to actual auth improves credibility and reduces mock drift. No issues spotted.
130-141: Confirm z-index fix actually targets the Radix popper wrapper.Wrapping with
.stack-scopewon’t affect the portal’d popper unless your CSS selector matches the Radix wrapper element itself. Validate that[data-radix-popper-content-wrapper] .stack-scopeactually applies; often you need to style[data-radix-popper-content-wrapper]directly.In DevTools with the menu open, inspect the popper and check computed z-index. If it isn’t > the header (
z-50/z-[80]), update CSS to:[data-radix-popper-content-wrapper]{ z-index: 100 !important; }Or scope via a parent container if needed:
.home-page [data-radix-popper-content-wrapper]{ z-index: 100 !important; }
65-68: Layout tweaks LGTM.Using
items-startand tighter spacing reads well in the demo.docs/src/components/layouts/home-layout.tsx (2)
3-3: ImportingUserButtonhere is appropriate.This file is a client component, but it doesn’t touch
@/stackdirectly; it relies on the app-levelStackProvider, which is correct.
99-99: Header container/z-index interplay: verify popover stacking over headers.Top bar uses
z-50and compact bar usesz-50/z-[80]. Ensure the UserButton popover’s z-index exceeds these to avoid clipping under the bars.Open the menu over both nav bars and confirm it renders above; if not, raise the popper wrapper z-index to ≥ 100.
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> Adds signin with Stack Auth, allowing users to sign into our docs. Features to come with this later down the line. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Add Stack Auth user authentication and UI enhancements with `UserButton` and updated import paths. > > - **Features**: > - Added `UserButton` for user authentication in `home-layout.tsx`, `shared-header.tsx`, and `stack-user-button-demo.tsx`. > - Introduced `Handler` component in `page.tsx` to integrate `stackServerApp` with `StackHandler`. > - Added `Loading` component in `loading.tsx` for loading screen. > - **Imports**: > - Updated `stackServerApp` import path in `layout.tsx`. > - **UI Enhancements**: > - Updated navbar layout in `home-layout.tsx` to include `UserButton` and improved social links. > - Enhanced `UserButtonDemo` to use real account data when signed in. > - **Configuration**: > - Configured `stackServerApp` in `stack.ts` with environment variables for authentication. > - **Documentation**: > - Updated `user-button.mdx` to reflect changes in `UserButton` component. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup> for 4aeed31. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> ---- <!-- ELLIPSIS_HIDDEN --> <!-- RECURSEML_SUMMARY:START --> ## Review by RecurseML _🔍 Review performed on [faf79e5..2659adc](stack-auth/stack-auth@faf79e5...2659adc22a41ab70f5131d72ab186b85a844e9e0)_ ✨ No bugs found, your code is sparkling clean <details> <summary>✅ Files analyzed, no issues (5)</summary> • `docs/src/components/stack-auth/stack-user-button-demo.tsx` • `docs/src/components/layouts/home-layout.tsx` • `docs/src/components/layouts/shared-header.tsx` • `docs/src/app/loading.tsx` • `docs/src/app/handler/[...stack]/page.tsx` </details> <details> <summary>⏭️ Files skipped (low suspicion) (4)</summary> • `docs/src/app/global.css` • `docs/src/app/layout.tsx` • `docs/src/stack.ts` • `docs/templates/components/user-button.mdx` </details> [](https://discord.gg/n3SsVDAW6U) <!-- RECURSEML_SUMMARY:END --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Added an account UserButton to desktop and mobile headers; refined navbar layout and branding. - Introduced a full-page handler route. - Added a global loading screen. - UserButton demo now uses your signed-in account when available, with clear status; falls back to mock data otherwise. - Documentation - Updated component docs to reference UserButton (replacing previous naming). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
Adds signin with Stack Auth, allowing users to sign into our docs. Features to come with this later down the line.
Important
Add Stack Auth user authentication and UI enhancements with
UserButtonand updated import paths.UserButtonfor user authentication inhome-layout.tsx,shared-header.tsx, andstack-user-button-demo.tsx.Handlercomponent inpage.tsxto integratestackServerAppwithStackHandler.Loadingcomponent inloading.tsxfor loading screen.stackServerAppimport path inlayout.tsx.home-layout.tsxto includeUserButtonand improved social links.UserButtonDemoto use real account data when signed in.stackServerAppinstack.tswith environment variables for authentication.user-button.mdxto reflect changes inUserButtoncomponent.This description was created by
for 4aeed31. You can customize this summary. It will automatically update as commits are pushed.
Review by RecurseML
🔍 Review performed on faf79e5..2659adc
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (5)
•
docs/src/components/stack-auth/stack-user-button-demo.tsx•
docs/src/components/layouts/home-layout.tsx•
docs/src/components/layouts/shared-header.tsx•
docs/src/app/loading.tsx•
docs/src/app/handler/[...stack]/page.tsx⏭️ Files skipped (low suspicion) (4)
•
docs/src/app/global.css•
docs/src/app/layout.tsx•
docs/src/stack.ts•
docs/templates/components/user-button.mdxSummary by CodeRabbit
New Features
Documentation