Conversation
Port the Impersonation component from authkit-nextjs, providing an admin banner when a user is being impersonated. Includes Button and MinMaxButton sub-components, a getOrganizationAction server function, and CSS custom property theming support.
Always-on fixture that only renders when a WorkOS admin is impersonating a user. Returns null otherwise.
Contributor
Greptile SummaryThis PR ports the Key Changes:
Issues Found:
The component architecture is solid, integrating seamlessly with existing Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Impersonation
participant useAuth
participant getOrganizationAction
participant WorkOS
User->>Impersonation: Render component
Impersonation->>useAuth: Get auth state
useAuth-->>Impersonation: user, impersonator, organizationId
alt No impersonation active
Impersonation-->>User: Render null
else Impersonation active
Impersonation-->>User: Render banner with user email
alt organizationId exists
Impersonation->>getOrganizationAction: Fetch organization details
getOrganizationAction->>WorkOS: Get organization by ID
WorkOS-->>getOrganizationAction: Organization data
getOrganizationAction-->>Impersonation: OrganizationInfo
Impersonation-->>User: Update banner with org name
end
User->>Impersonation: Click Stop button
Impersonation->>useAuth: Call signOut with returnTo
useAuth-->>User: Redirect to sign out
end
Last reviewed commit: c78646f |
Remove forwardRef from internal Button, switch to named React imports to match codebase convention, extract mockAuth helper in tests to reduce repetition (270 → 165 lines), trim verbose doc comments.
Member
Author
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
gjtorikian
approved these changes
Mar 2, 2026
Misplaced closing paren caused template literal `}` to be parsed as the arrow function body terminator.
Return null instead of letting the WorkOS SDK exception propagate. Removes client-side .catch() since null is handled naturally. Adds tests for success and not-found cases.
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.
Summary
Port the
Impersonationcomponent fromauthkit-nextjsto provide a built-in admin banner when a WorkOS admin is impersonating a user. The component is framework-agnostic (plain React + CSS variables) and wires into the existinguseAuth()hook and server function patterns.Impersonation,Button, andMinMaxButtoncomponents to@workos/authkit-tanstack-react-start/clientgetOrganizationActionserver function to fetch org details for the impersonation bannerstylepropUsage
The component renders nothing when no impersonation is active. When a WorkOS admin impersonates a user, it displays a fixed banner with the impersonated user's email, organization name, and a "Stop" button.
Props
side'top' | 'bottom''bottom'returnTostringundefinedTheming via CSS variables
--workos-impersonation-size4px--workos-impersonation-background-color#fce654--workos-impersonation-color#1a1600--workos-impersonation-border-color#e0c36c--workos-impersonation-border-width1px