WorkOS Widgets
Workflow Overview
- Identify widget target from the user request (
user-management, user-profile, admin-portal-sso-connection, admin-portal-domain-verification).
- Scan project files in this order:
- package/dependency manifests
- framework/router entrypoints
- auth/token utilities
- styling/component patterns
- Detect stack, data-layer style, styling, component system, and package manager using references/detection.md.
- Check for AuthKit/WorkOS presence:
- if detected, continue;
- if not detected, ask the user to run
WORKOS_MODE=agent npx workos@latest install. Wait for confirmation, then continue.
- If detection is ambiguous or conflicting, ask one focused question, then continue.
- Load only the relevant reference files for the detected stack and widget.
- Implement integration based on stack shape:
- frontend route/page + widget component when widget UI lives in the same app
- token endpoint/service + client integration surface when backend-first/multi-app architecture is detected
- Validate routing/wiring, imports, and token/API usage before finishing.
Canonical Inputs
Accept these inputs from the user request when available:
- widget type (or infer from request intent)
- optional component path
- optional page/route path
- optional token endpoint/service preference
- optional constraints (for example: avoid broad refactors)
When input is missing, infer from existing project conventions and detected stack.
Detection and Ambiguity Protocol
- Apply detection heuristics from references/detection.md.
- Explore before asking. Ask only when ambiguity remains after checking manifests and route/auth entrypoints.
- Ask a single concrete question that resolves one decision.
- Default to the strongest detected ownership signals when no user response is available.
- When installs are required, use the package manager detected from project files/lockfiles.
Reference Loading Map
Always load these core references:
- references/detection.md
- references/token-strategies.md
- references/fetching-apis.md
- references/styling-and-components.md
For React/TypeScript stacks (Next.js, React Router, TanStack Router, TanStack Start, Vite), also load:
- references/react-ts-standards.md
Load stack-specific reference guidance:
- Next.js: references/framework-nextjs.md
- React Router: references/framework-react-router.md
- TanStack Router: references/framework-tanstack-router.md
- TanStack Start: references/framework-tanstack-start.md
- Vite: references/framework-vite.md
- SvelteKit: references/framework-sveltekit.md
- Ruby: references/framework-ruby.md
- Python: references/framework-python.md
- Go: references/framework-go.md
- PHP: references/framework-php.md
- Java: references/framework-java.md
- Mixed repositories: references/framework-mixed-repositories.md
Then load exactly one widget reference:
- User Management: references/widget-user-management.md
- User Profile: references/widget-user-profile.md
- Admin Portal SSO Connection: references/widget-admin-portal-sso-connection.md
- Admin Portal Domain Verification: references/widget-admin-portal-domain-verification.md
Global Widget Guidance
Core Guidelines
- Reuse existing domain types from the host project and OpenAPI schemas; avoid duplicating model definitions.
- Build widget requests using references/fetching-apis.md for paths, methods, and schema queries.
- Use direct
fetch/HTTP calls (or equivalent server HTTP client) for endpoint calls.
- Implement a consistent authorization layer for widget requests, including elevated-token handling for sensitive endpoints when required.
- If the app already uses React Query or SWR, use them as orchestration/cache layers around those direct calls.
- For React/TypeScript widget code quality expectations, follow references/react-ts-standards.md.
- If AuthKit/WorkOS is missing, prompt the user to run
WORKOS_MODE=agent npx workos@latest install before continuing. WORKOS_MODE=agent keeps the installer deterministic (no prompts, no browser, no host-trust); pass --json when you need to parse the output.
- Install additional dependencies only when strictly necessary, using the detected package manager/tooling.
- Keep server-state handling aligned with the selected data-layer approach.
- Use local state/reducers for UI interaction state as needed.
- Prefer existing design system and styling conventions.
- Avoid broad unrelated refactors and global style rewrites.
Completion Requirements
Before finishing, verify all relevant items:
- Widget component exists and accepts
accessToken: string when component-level integration is in scope.
- Route/page wiring is complete when route integration is in scope.
- Token source matches existing app architecture (AuthKit client flow or backend WorkOS token flow).
- API methods and paths match the bundled OpenAPI spec, and data-layer usage matches project conventions.
- Loading and error branches exist for required query/mutation flows.
Validation Checklist
- Confirm endpoint paths and HTTP methods come from the bundled OpenAPI spec.
- Confirm request/response handling follows schema expectations from the spec.
- Confirm query/mutation invalidation/refetch is applied after successful mutations where required.
- Confirm empty/error/loading states are explicit and user-visible.
- Confirm package installs (if any) used the detected package manager/tooling.
- Confirm implementation stays aligned with existing codebase conventions.
- Confirm no existing component has been passed
className or style props to override its built-in styling. Use each component as-is or via its own props API (variant, size, etc.).
1---2name: workos-widgets3description: Use when the user is implementing, embedding, or debugging a WorkOS Widget — specifically the User Management, User Profile, Admin Portal SSO Connection, or Admin Portal Domain Verification widgets. Handles the full stack — detecting the frontend (Next.js, React, React Router, TanStack Start, Vite, SvelteKit), generating access tokens via the backend SDK in use (Node, Python, Go, Ruby, PHP, Java, .NET), and wiring up the widget component correctly per the bundled OpenAPI spec. Also use when code imports from @workos-inc/widgets or the user pastes <UserManagement /> or <UserProfile /> JSX.4---5
6# WorkOS Widgets
7
8## Workflow Overview
9
101. Identify widget target from the user request (`user-management`, `user-profile`, `admin-portal-sso-connection`, `admin-portal-domain-verification`).
112. Scan project files in this order:
12 - package/dependency manifests
13 - framework/router entrypoints
14 - auth/token utilities
15 - styling/component patterns
163. Detect stack, data-layer style, styling, component system, and package manager using [references/detection.md](references/detection.md).
174. Check for AuthKit/WorkOS presence:
18 - if detected, continue;
19 - if not detected, ask the user to run `WORKOS_MODE=agent npx workos@latest install`. Wait for confirmation, then continue.
205. If detection is ambiguous or conflicting, ask one focused question, then continue.
216. Load only the relevant reference files for the detected stack and widget.
227. Implement integration based on stack shape:
23 - frontend route/page + widget component when widget UI lives in the same app
24 - token endpoint/service + client integration surface when backend-first/multi-app architecture is detected
258. Validate routing/wiring, imports, and token/API usage before finishing.
26
27## Canonical Inputs
28
29Accept these inputs from the user request when available:
30
31- widget type (or infer from request intent)
32- optional component path
33- optional page/route path
34- optional token endpoint/service preference
35- optional constraints (for example: avoid broad refactors)
36
37When input is missing, infer from existing project conventions and detected stack.
38
39## Detection and Ambiguity Protocol
40
41- Apply detection heuristics from [references/detection.md](references/detection.md).
42- Explore before asking. Ask only when ambiguity remains after checking manifests and route/auth entrypoints.
43- Ask a single concrete question that resolves one decision.
44- Default to the strongest detected ownership signals when no user response is available.
45- When installs are required, use the package manager detected from project files/lockfiles.
46
47## Reference Loading Map
48
49Always load these core references:
50
51- [references/detection.md](references/detection.md)
52- [references/token-strategies.md](references/token-strategies.md)
53- [references/fetching-apis.md](references/fetching-apis.md)
54- [references/styling-and-components.md](references/styling-and-components.md)
55
56For React/TypeScript stacks (Next.js, React Router, TanStack Router, TanStack Start, Vite), also load:
57
58- [references/react-ts-standards.md](references/react-ts-standards.md)
59
60Load stack-specific reference guidance:
61
62- Next.js: [references/framework-nextjs.md](references/framework-nextjs.md)
63- React Router: [references/framework-react-router.md](references/framework-react-router.md)
64- TanStack Router: [references/framework-tanstack-router.md](references/framework-tanstack-router.md)
65- TanStack Start: [references/framework-tanstack-start.md](references/framework-tanstack-start.md)
66- Vite: [references/framework-vite.md](references/framework-vite.md)
67- SvelteKit: [references/framework-sveltekit.md](references/framework-sveltekit.md)
68- Ruby: [references/framework-ruby.md](references/framework-ruby.md)
69- Python: [references/framework-python.md](references/framework-python.md)
70- Go: [references/framework-go.md](references/framework-go.md)
71- PHP: [references/framework-php.md](references/framework-php.md)
72- Java: [references/framework-java.md](references/framework-java.md)
73- Mixed repositories: [references/framework-mixed-repositories.md](references/framework-mixed-repositories.md)
74
75Then load exactly one widget reference:
76
77- User Management: [references/widget-user-management.md](references/widget-user-management.md)
78- User Profile: [references/widget-user-profile.md](references/widget-user-profile.md)
79- Admin Portal SSO Connection: [references/widget-admin-portal-sso-connection.md](references/widget-admin-portal-sso-connection.md)
80- Admin Portal Domain Verification: [references/widget-admin-portal-domain-verification.md](references/widget-admin-portal-domain-verification.md)
81
82## Global Widget Guidance
83
84- Implement widget operations using endpoint paths/methods from [references/fetching-apis.md](references/fetching-apis.md). When building request bodies or parsing responses, query the OpenAPI spec for the relevant widget's schemas:
85 ```bash
86 node references/scripts/query-spec.cjs --widget <widget-name>
87 ```
88 Use `--list` to see available widget groups.
89- Keep loading, empty, and error states explicit and user-visible.
90- Keep mutation outcomes visible and refresh/reload affected data after successful changes.
91- Align table/list/action UI with existing project conventions.
92- Keep behavior resilient for partial/optional data and avoid brittle UI assumptions.
93
94## Core Guidelines
95
96- Reuse existing domain types from the host project and OpenAPI schemas; avoid duplicating model definitions.
97- Build widget requests using [references/fetching-apis.md](references/fetching-apis.md) for paths, methods, and schema queries.
98- Use direct `fetch`/HTTP calls (or equivalent server HTTP client) for endpoint calls.
99- Implement a consistent authorization layer for widget requests, including elevated-token handling for sensitive endpoints when required.
100- If the app already uses React Query or SWR, use them as orchestration/cache layers around those direct calls.
101- For React/TypeScript widget code quality expectations, follow [references/react-ts-standards.md](references/react-ts-standards.md).
102- If AuthKit/WorkOS is missing, prompt the user to run `WORKOS_MODE=agent npx workos@latest install` before continuing. `WORKOS_MODE=agent` keeps the installer deterministic (no prompts, no browser, no host-trust); pass `--json` when you need to parse the output.
103- Install additional dependencies only when strictly necessary, using the detected package manager/tooling.
104- Keep server-state handling aligned with the selected data-layer approach.
105- Use local state/reducers for UI interaction state as needed.
106- Prefer existing design system and styling conventions.
107- Avoid broad unrelated refactors and global style rewrites.
108
109## Completion Requirements
110
111Before finishing, verify all relevant items:
112
1131. Widget component exists and accepts `accessToken: string` when component-level integration is in scope.
1142. Route/page wiring is complete when route integration is in scope.
1153. Token source matches existing app architecture (AuthKit client flow or backend WorkOS token flow).
1164. API methods and paths match the bundled OpenAPI spec, and data-layer usage matches project conventions.
1175. Loading and error branches exist for required query/mutation flows.
118
119## Validation Checklist
120
1211. Confirm endpoint paths and HTTP methods come from the bundled OpenAPI spec.
1222. Confirm request/response handling follows schema expectations from the spec.
1233. Confirm query/mutation invalidation/refetch is applied after successful mutations where required.
1244. Confirm empty/error/loading states are explicit and user-visible.
1255. Confirm package installs (if any) used the detected package manager/tooling.
1266. Confirm implementation stays aligned with existing codebase conventions.
1277. Confirm no existing component has been passed `className` or `style` props to override its built-in styling. Use each component as-is or via its own props API (`variant`, `size`, etc.).