Skip to content

[Docs][site] - Add signin functionality#876

Merged
madster456 merged 17 commits intodevfrom
docs-signin
Sep 10, 2025
Merged

[Docs][site] - Add signin functionality#876
madster456 merged 17 commits intodevfrom
docs-signin

Conversation

@madster456
Copy link
Collaborator

@madster456 madster456 commented Sep 3, 2025

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 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.

This description was created by Ellipsis 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.mdx

Need help? Join our Discord

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).

@vercel
Copy link

vercel bot commented Sep 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stack-backend Ready Ready Preview Comment Sep 10, 2025 6:02am
stack-dashboard Ready Ready Preview Comment Sep 10, 2025 6:02am
stack-demo Ready Ready Preview Comment Sep 10, 2025 6:02am
stack-docs Ready Ready Preview Comment Sep 10, 2025 6:02am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Adds 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

Cohort / File(s) Summary
App routing and shell
docs/src/app/handler/[...stack]/page.tsx, docs/src/app/layout.tsx, docs/src/app/loading.tsx
New handler page renders StackHandler with stackServerApp and forwards route props; layout import path switched to @/stack; adds a global “Loading...” fallback.
Header and layout integrations
docs/src/components/layouts/home-layout.tsx, docs/src/components/layouts/shared-header.tsx
Integrates UserButton into desktop/mobile headers; restructures compact navbar (logo placement, action clusters, icon sizes); standardizes inner container width; preserves existing search/chat/theme behaviors.
Stack Auth configuration
docs/src/stack.ts
Extends StackServerApp initialization with env-based options: projectId, publishableClientKey, secretServerKey, baseUrl; retains tokenStore.
Component demo behavior
docs/src/components/stack-auth/stack-user-button-demo.tsx
Uses useUser() to switch between real user and mock data; updates demo layout/styling and status indicator; adjusts mock user shape; removes StackContainer.
Documentation wording
docs/templates/components/user-button.mdx
Updates text to reference <UserButton> instead of <StackUserButton>; content otherwise unchanged.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through routes where handlers play,
A loading glow to light the way.
With buttons for users, I twitch my nose—
Env keys tucked where config goes.
The navbar’s neat, the docs now bright;
I thump approval—ship it tonight! 🐇✨


📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 2659adc and 4aeed31.

📒 Files selected for processing (1)
  • docs/templates/components/user-button.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/templates/components/user-button.mdx
⏰ 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: lint_and_build (latest)
  • GitHub Check: build (22.x)
  • GitHub Check: all-good
  • GitHub Check: build (22.x)
  • GitHub Check: docker
  • GitHub Check: setup-tests
  • GitHub Check: restart-dev-and-test
  • GitHub Check: docker
  • GitHub Check: Security Check
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs-signin

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts and docs/templates/components/user-button.mdx

9 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (6)
docs/src/app/loading.tsx (1)

1-7: Add basic a11y semantics to the loading UI

Expose 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 unknown for 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, use user != 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 UserButton renders only an avatar without visible text, confirm it includes an internal aria-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-label on 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.

📥 Commits

Reviewing files that changed from the base of the PR and between faf79e5 and 2659adc.

📒 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.tsx
  • docs/src/app/layout.tsx
  • docs/src/stack.ts
  • docs/src/app/handler/[...stack]/page.tsx
  • docs/src/components/layouts/shared-header.tsx
  • docs/src/components/stack-auth/stack-user-button-demo.tsx
  • docs/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 UserButton

Import 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 confirmed
docs/src/components/stack-auth/stack-user-button-demo.tsx (3)

3-3: Good: real user state via useUser.

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-scope won’t affect the portal’d popper unless your CSS selector matches the Radix wrapper element itself. Validate that [data-radix-popper-content-wrapper] .stack-scope actually 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-start and tighter spacing reads well in the demo.

docs/src/components/layouts/home-layout.tsx (2)

3-3: Importing UserButton here is appropriate.

This file is a client component, but it doesn’t touch @/stack directly; it relies on the app-level StackProvider, which is correct.


99-99: Header container/z-index interplay: verify popover stacking over headers.

Top bar uses z-50 and compact bar uses z-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.

@madster456 madster456 requested a review from N2D4 September 3, 2025 22:06
@madster456 madster456 changed the title update stackServerApp import Docs - Signin Sep 3, 2025
@madster456 madster456 changed the title Docs - Signin [Docs][site] - Add signin functionality Sep 5, 2025
@N2D4 N2D4 removed their assignment Sep 9, 2025
@madster456 madster456 merged commit bc2b7a1 into dev Sep 10, 2025
18 checks passed
@madster456 madster456 deleted the docs-signin branch September 10, 2025 06:32
sicarius97 pushed a commit to sicarius97/stack-auth that referenced this pull request Sep 10, 2025
<!--

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>

[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](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>
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