examples: Update WorkOS example to use new AuthKit SDK #5394
main fromrefs/pull/5394/head·merged by schiller-manuel(GitHub profile, opens in a new tab) This PR updates the start-workos example to use the new @workos/authkit-tanstack-react-start SDK instead of the custom implementation.
What changed#
- Replaced custom AuthKit implementation with the official SDK package
- Removed all the manual session management, cookie handling, and JWKS verification code
- Updated routes to use the SDK's built-in
getAuth()andgetSignInUrl()server functions - Added
AuthKitProviderfor client-side auth state management
Why#
We built an official SDK that handles all the AuthKit integration details, so this example should demonstrate the recommended approach rather than a custom implementation. Makes the example cleaner and easier to follow.
Summary by CodeRabbit#
New Features
- Added a Client Demo page showing client-side auth hooks, tokens, org switching, and sign-out methods; linked in navigation.
- Integrated an AuthKit provider so loaders use new auth APIs for user and sign-in URLs.
Refactor
- Replaced local SSR auth implementation with the external AuthKit integration.
Chores
- Added AuthKit dependency, Radix theme CSS, Vite SSR tweak, and CSS URL TypeScript declarations.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
View your CI Pipeline Execution ↗ for commit 136b1c338eb2ec4aafd8ead80ebf020fad90b991
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 14m 11s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 22s View ↗
☁️ Nx Cloud last updated this comment at
2026-02-05 21:25:18UTCMore templates
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5394@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5394@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5394@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5394@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5394@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5394@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5394@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5394@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5394@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5394@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5394@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5394@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5394@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5394@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5394@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5394@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5394@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5394@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5394@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5394@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5394@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5394@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5394@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5394@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5394@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5394@tanstack/start-fn-stubs
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@5394@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5394@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5394@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5394@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5394@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5394@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5394@tanstack/vue-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@5394@tanstack/vue-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@5394@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@5394@tanstack/vue-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@5394@tanstack/vue-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@5394@tanstack/vue-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@5394@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5394commit:
136b1c3Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between a5fdf290cb9be6a640a0dc85d29c75fd83081f11 and 4a0989764b2e455e90bbe36239f878279e033e2d.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (20)
examples/react/start-workos/package.json(2 hunks)examples/react/start-workos/src/app.css(1 hunks)examples/react/start-workos/src/authkit/serverFunctions.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/config.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/interfaces.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/session.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/utils.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/workos.ts(0 hunks)examples/react/start-workos/src/routeTree.gen.ts(8 hunks)examples/react/start-workos/src/routes/__root.tsx(3 hunks)examples/react/start-workos/src/routes/_authenticated.tsx(1 hunks)examples/react/start-workos/src/routes/_authenticated/account.tsx(1 hunks)examples/react/start-workos/src/routes/api/auth/callback.tsx(1 hunks)examples/react/start-workos/src/routes/client.tsx(1 hunks)examples/react/start-workos/src/routes/index.tsx(2 hunks)examples/react/start-workos/src/routes/logout.tsx(1 hunks)examples/react/start-workos/src/start.ts(1 hunks)examples/react/start-workos/src/vite-env.d.ts(1 hunks)examples/react/start-workos/vite.config.ts(2 hunks)packages/start-server-core/package.json(1 hunks)
💤 Files with no reviewable changes (6)
- examples/react/start-workos/src/authkit/ssr/utils.ts
- examples/react/start-workos/src/authkit/ssr/session.ts
- examples/react/start-workos/src/authkit/ssr/interfaces.ts
- examples/react/start-workos/src/authkit/serverFunctions.ts
- examples/react/start-workos/src/authkit/ssr/workos.ts
- examples/react/start-workos/src/authkit/ssr/config.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
examples/react/start-workos/src/vite-env.d.tsexamples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/src/start.tsexamples/react/start-workos/src/routes/logout.tsxexamples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routeTree.gen.tsexamples/react/start-workos/src/routes/client.tsxexamples/react/start-workos/vite.config.tsexamples/react/start-workos/src/routes/_authenticated.tsxexamples/react/start-workos/src/routes/__root.tsx
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/start-workos/src/vite-env.d.tsexamples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/app.cssexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/src/start.tsexamples/react/start-workos/src/routes/logout.tsxexamples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routeTree.gen.tsexamples/react/start-workos/package.jsonexamples/react/start-workos/src/routes/client.tsxexamples/react/start-workos/vite.config.tsexamples/react/start-workos/src/routes/_authenticated.tsxexamples/react/start-workos/src/routes/__root.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
examples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/src/routes/logout.tsxexamples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routes/client.tsxexamples/react/start-workos/src/routes/_authenticated.tsxexamples/react/start-workos/src/routes/__root.tsx
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
packages/start-server-core/package.jsonexamples/react/start-workos/package.json
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-server-core/package.json
🧬 Code graph analysis (7)
examples/react/start-workos/src/routes/index.tsx (3)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/_authenticated/account.tsx (1)
Route(5-27)
examples/react/start-workos/src/routes/api/auth/callback.tsx (2)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/_authenticated/account.tsx (3)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/index.tsx (1)
Route(6-13)
examples/react/start-workos/src/routeTree.gen.ts (2)
packages/router-core/src/router.ts (1)
Register(97-102)
examples/react/start-workos/src/router.tsx (1)
getRouter(4-11)
examples/react/start-workos/src/routes/client.tsx (6)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/_authenticated/account.tsx (1)
Route(5-27)
examples/react/start-workos/src/routes/api/auth/callback.tsx (1)
Route(4-10)
examples/react/start-workos/src/routes/index.tsx (1)
Route(6-13)
examples/react/start-workos/src/routes/logout.tsx (1)
Route(4-9)
examples/react/start-workos/src/routes/_authenticated.tsx (3)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated/account.tsx (1)
Route(5-27)
examples/react/start-workos/src/routes/index.tsx (1)
Route(6-13)
examples/react/start-workos/src/routes/__root.tsx (1)
examples/react/start-workos/src/components/sign-in-button.tsx (1)
SignInButton(5-21)
⏰ 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). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (8)
examples/react/start-workos/vite.config.ts (2)
21-23: LGTM!The
ssr.noExternalconfiguration for@radix-ui/themesis correct. Radix UI components need to be bundled during SSR rather than externalized, as they rely on client-side dependencies that must be transformed.
5-8: No action required:.env.exampleand README.md document the required environment variables.examples/react/start-workos/src/vite-env.d.ts (1)
1-6: LGTM!The Vite client typings and CSS URL module declaration are correctly configured. This enables TypeScript to properly type CSS imports with the
?urlsuffix (e.g.,import appCssUrl from './app.css?url'), which is used in the root route.examples/react/start-workos/src/app.css (1)
1-1: LGTM!The Radix UI themes stylesheet import is correctly configured and will be loaded via the URL import pattern in the root route.
examples/react/start-workos/src/start.ts (1)
8-13: LGTM!The Start instance configuration correctly integrates the AuthKit middleware. The middleware will run on every server request, providing authentication context to route loaders and server functions.
examples/react/start-workos/src/routes/logout.tsx (1)
2-2: LGTM!The import change from local implementation to the external SDK is correct and aligns with the PR's objective of using the official AuthKit SDK. The
signOutfunction usage remains unchanged, preserving existing behavior.examples/react/start-workos/src/routes/api/auth/callback.tsx (1)
2-9: LGTM!Delegating the OAuth callback handling to
handleCallbackRoutefrom the external SDK simplifies the code significantly. The SDK now handles token exchange, session management, state validation, and redirects, reducing custom implementation complexity and potential security issues.packages/start-server-core/package.json (1)
79-79: Vite devDependency is intentional:start-server-coredefines a"build": "vite build"script and includesvite.config.ts, so adding"vite": "^7.1.7"is required.Likely an incorrect or invalid review comment.
examples/react/start-workos/package.json line 21Outdated@@ -18,3 +18,4 @@1818 "@tanstack/react-router-devtools": "^1.132.47",1919 "@tanstack/react-start": "^1.132.47",2020 "@workos-inc/node": "^7.45.0",21+ "@workos/authkit-tanstack-react-start": "^0.1.0",⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
Verify stability and breaking change expectations for the 0.1.x SDK.
The
@workos/authkit-tanstack-react-startpackage is at version^0.1.0, which indicates it's in early development. Pre-1.0 versions may introduce breaking changes in minor/patch releases. Consider pinning to an exact version or documenting this dependency risk.
🌐 Web query:
What is the latest stable version of @workos/authkit-tanstack-react-start and its release stability policy?💡 Result:
I couldn't find any published npm package named "@workos/authkit-tanstack-react-start". Searches of npm/GitHub and WorkOS docs show WorkOS publishes AuthKit packages under @workos-inc (e.g. @workos-inc/authkit-react and @workos-inc/authkit-react-router), and the TanStack Start docs include a WorkOS example (not a package with the name you gave). [1][2][3]
If you meant a different package name, or a workspace/example repo, tell me the exact npm/GitHub package or repo and I’ll look it up. References:
- WorkOS AuthKit docs and packages. [1]
- WorkOS GitHub (authkit-react, authkit-nextjs, authkit-react-router). [2]
- TanStack Start React — WorkOS example (Start + WorkOS). [3]
Sources: [1] https://workos.com/docs/authkit/react [2] https://github.com/workos [3] https://tanstack.com/start/latest/docs/framework/react/examples/start-workos
Correct invalid package dependency The dependency
"@workos/authkit-tanstack-react-start"isn’t published on npm; WorkOS AuthKit packages live under the@workos-incscope (e.g.@workos-inc/authkit-react). Update line 21 ofexamples/react/start-workos/package.jsonto the correct package name and version.🤖 Prompt for AI Agents
examples/react/start-workos/package.json around line 21: Replace the invalid dependency "@workos/authkit-tanstack-react-start" with the correct scoped package name and version, e.g. "@workos-inc/authkit-react": "^0.1.0" (or the exact published version you need), then save and run npm/yarn install to update lockfiles.note: we have both the
@workosand@workos-incnamespaces on npm. We've been working on a way to transition from@workos-incto@workosbecause it's simpler and since this SDK was brand new, I figured I'd just start there. I can accelerate my idea to dual-publish if this is an issue.Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
nicknisi(GitHub profile, opens in a new tab)replied on
examples/react/start-workos/package.jsonline 21note: we have both the
@workosand@workos-incnamespaces on npm. We've been working on a way to transition from@workos-incto@workosbecause it's simpler and since this SDK was brand new, I figured I'd just start there. I can accelerate my idea to dual-publish if this is an issue.coderabbitai[bot](GitHub profile, opens in a new tab)replied on
examples/react/start-workos/package.jsonline 21Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
- @@ -75,4 +75,5 @@7575 "devDependencies": {7676 "@standard-schema/spec": "^1.0.0",7777 "cookie-es": "^2.0.0",78- "fetchdts": "^0.1.6"78+ "fetchdts": "^0.1.6",79+ "vite": "^7.1.7"
why do we need
vitehere?I think at the time I was having build issues without that - I rebased and tried again and was able to remove it. Thanks!
schiller-manuel(GitHub profile, opens in a new tab) changed the title
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 4a0989764b2e455e90bbe36239f878279e033e2d and a13f1e1a0c05f13fb20004a760f1534146aef64c.
📒 Files selected for processing (19)
examples/react/start-workos/package.json(2 hunks)examples/react/start-workos/src/app.css(1 hunks)examples/react/start-workos/src/authkit/serverFunctions.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/config.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/interfaces.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/session.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/utils.ts(0 hunks)examples/react/start-workos/src/authkit/ssr/workos.ts(0 hunks)examples/react/start-workos/src/routeTree.gen.ts(8 hunks)examples/react/start-workos/src/routes/__root.tsx(3 hunks)examples/react/start-workos/src/routes/_authenticated.tsx(1 hunks)examples/react/start-workos/src/routes/_authenticated/account.tsx(1 hunks)examples/react/start-workos/src/routes/api/auth/callback.tsx(1 hunks)examples/react/start-workos/src/routes/client.tsx(1 hunks)examples/react/start-workos/src/routes/index.tsx(2 hunks)examples/react/start-workos/src/routes/logout.tsx(1 hunks)examples/react/start-workos/src/start.ts(1 hunks)examples/react/start-workos/src/vite-env.d.ts(1 hunks)examples/react/start-workos/vite.config.ts(2 hunks)
💤 Files with no reviewable changes (6)
- examples/react/start-workos/src/authkit/ssr/utils.ts
- examples/react/start-workos/src/authkit/ssr/workos.ts
- examples/react/start-workos/src/authkit/ssr/config.ts
- examples/react/start-workos/src/authkit/ssr/interfaces.ts
- examples/react/start-workos/src/authkit/serverFunctions.ts
- examples/react/start-workos/src/authkit/ssr/session.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- examples/react/start-workos/src/routes/logout.tsx
- examples/react/start-workos/package.json
- examples/react/start-workos/src/app.css
- examples/react/start-workos/src/routes/client.tsx
- examples/react/start-workos/src/routes/_authenticated.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
examples/react/start-workos/src/vite-env.d.tsexamples/react/start-workos/src/start.tsexamples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/vite.config.tsexamples/react/start-workos/src/routeTree.gen.tsexamples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/routes/__root.tsx
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/start-workos/src/vite-env.d.tsexamples/react/start-workos/src/start.tsexamples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/vite.config.tsexamples/react/start-workos/src/routeTree.gen.tsexamples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/routes/__root.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
examples/react/start-workos/src/routes/_authenticated/account.tsxexamples/react/start-workos/src/routes/api/auth/callback.tsxexamples/react/start-workos/src/routes/index.tsxexamples/react/start-workos/src/routes/__root.tsx
🧬 Code graph analysis (5)
examples/react/start-workos/src/routes/_authenticated/account.tsx (3)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/index.tsx (1)
Route(6-13)
examples/react/start-workos/src/routes/api/auth/callback.tsx (2)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routeTree.gen.ts (2)
packages/router-core/src/router.ts (1)
Register(97-102)
examples/react/start-workos/src/router.tsx (1)
getRouter(4-11)
examples/react/start-workos/src/routes/index.tsx (5)
examples/react/start-workos/src/routes/__root.tsx (1)
Route(12-39)
examples/react/start-workos/src/routes/_authenticated.tsx (1)
Route(4-14)
examples/react/start-workos/src/routes/_authenticated/account.tsx (1)
Route(5-27)
examples/react/start-workos/src/routes/api/auth/callback.tsx (1)
Route(4-10)
examples/react/start-workos/src/routes/logout.tsx (1)
Route(4-9)
examples/react/start-workos/src/routes/__root.tsx (2)
examples/react/start-workos/src/components/sign-in-button.tsx (1)
SignInButton(5-21)
examples/react/start-workos/src/components/footer.tsx (1)
Footer(3-32)
🪛 ESLint
examples/react/start-workos/src/routes/__root.tsx
[error] 10-10:
../app.css?urlimport should occur before type import ofreact(import/order)
⏰ 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). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (10)
examples/react/start-workos/vite.config.ts (2)
5-8: LGTM: dotenv configuration is appropriate for the WorkOS SDK.Loading environment variables at the module level ensures they're available before the SDK initializes.
21-23: LGTM: SSR configuration correctly handles Radix UI.Including
@radix-ui/themesinnoExternalensures the theme components are properly bundled for server-side rendering.examples/react/start-workos/src/routes/_authenticated/account.tsx (1)
7-26: LGTM: Loader correctly migrated to use SDK.The loader properly uses
getAuth()from the SDK and correctly handles optional role and permissions fields. The runtime checks ensure proper handling when these properties are absent.examples/react/start-workos/src/vite-env.d.ts (1)
1-6: LGTM: TypeScript declaration correctly enables CSS URL imports.This declaration allows importing CSS files as URLs (e.g.,
import url from './style.css?url'), which is used in the root route to add a stylesheet link.examples/react/start-workos/src/start.ts (1)
1-13: LGTM: Start configuration correctly integrates AuthKit middleware.The middleware setup ensures authentication context is available for all server functions like
getAuth()andgetSignInUrl()throughout the application.examples/react/start-workos/src/routes/api/auth/callback.tsx (1)
1-10: LGTM: Callback route properly delegates to SDK.Replacing the custom callback implementation with
handleCallbackRoutefrom the SDK simplifies the code and ensures the example follows the recommended approach.examples/react/start-workos/src/routes/index.tsx (2)
3-12: LGTM: Route correctly migrated to use SDK.The loader properly uses
getAuth()andgetSignInUrl()from the SDK, following the same pattern as other routes in this migration.
24-24: Minor UI text improvement.Updated text more specifically identifies this as a TanStack Start application.
examples/react/start-workos/src/routes/__root.tsx (2)
5-6: LGTM: Root route properly migrated to use SDK.The loader correctly uses
getAuth()andgetSignInUrl()from the SDK, replacing the previousbeforeLoadapproach. This ensures authentication data is available during client-side navigation.Also applies to: 28-36
45-87: LGTM: AuthKitProvider correctly wraps the application.The
AuthKitProviderintegration enables client-side auth state management throughout the component tree, which is essential for the SDK's client-side functionality.@@ -1,9 +1,10 @@11 import { Box, Button, Card, Container, Flex, Theme } from '@radix-ui/themes';2-import '@radix-ui/themes/styles.css';32 import { HeadContent, Link, Outlet, Scripts, createRootRoute } from '@tanstack/react-router';43 import { TanStackRouterDevtools } from '@tanstack/react-router-devtools';54 import { Suspense } from 'react';6-import { getAuth, getSignInUrl } from '../authkit/serverFunctions';5+import { getAuth, getSignInUrl } from '@workos/authkit-tanstack-react-start';6+import { AuthKitProvider } from '@workos/authkit-tanstack-react-start/client';77 import Footer from '../components/footer';88 import SignInButton from '../components/sign-in-button';99 import type { ReactNode } from 'react';10+import appCssUrl from '../app.css?url';⚠️ Potential issue | 🟡 Minor
Fix import order to comply with ESLint rules.
The static analysis tool correctly identifies that the CSS URL import should occur before type imports.
As per coding guidelines
Apply this diff to fix the import order:
import SignInButton from '../components/sign-in-button'; -import type { ReactNode } from 'react'; import appCssUrl from '../app.css?url'; +import type { ReactNode } from 'react';📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import SignInButton from '../components/sign-in-button'; import appCssUrl from '../app.css?url'; import type { ReactNode } from 'react';🧰 Tools
🪛 ESLint
[error] 10-10:
../app.css?urlimport should occur before type import ofreact(import/order)
🤖 Prompt for AI Agents
In examples/react/start-workos/src/routes/__root.tsx around line 10, the import ordering is incorrect: the CSS URL import should appear before any type-only imports to satisfy ESLint rules; reorder imports so that the static asset import (import appCssUrl from '../app.css?url';) is placed above the type imports (or any other imports marked as type) thereby restoring the correct import sequence.✅ Addressed in commit 1608437
nicknisi(GitHub profile, opens in a new tab)replied on
packages/start-server-core/package.jsonline 79I think at the time I was having build issues without that - I rebased and tried again and was able to remove it. Thanks!
Actionable comments posted: 0
🧹 Nitpick comments (2)
examples/react/start-workos/src/routes/__root.tsx (2)
28-31: Make loader calls concurrent or skip sign‑in URL when authenticated.Both calls are independent; either run them together or avoid fetching the URL if a user exists.
Option A — concurrent:
- loader: async () => { - // getAuth() is a server function - works during client-side navigation - const { user } = await getAuth(); - const url = await getSignInUrl(); - return { user, url }; - }, + loader: async () => { + const [{ user }, url] = await Promise.all([getAuth(), getSignInUrl()]); + return { user, url }; + },Option B — skip when logged in:
- loader: async () => { - const { user } = await getAuth(); - const url = await getSignInUrl(); - return { user, url }; - }, + loader: async () => { + const { user } = await getAuth(); + const url = user ? '' : await getSignInUrl(); + return { user, url }; + },
45-87: Hydration not supported; retain layout improvements.AuthKitProvider does not expose
initialUseror hydrate props—it obtains the user from the client flow and performs its own fetch. Remove the hydration suggestion.The other recommendations remain valid:
SuspensearoundSignInButtonis unnecessary; consider moving it around<Outlet />(which is more likely to suspend) or remove it.- Prefer
min-height: 100dvhoverheight="100vh"for mobile browser chrome.
Example tweaks:
- <Flex direction="column" gap="5" p="5" height="100vh"> + <Flex direction="column" gap="5" p="5" style={{ minHeight: '100dvh' }}> ... - <Suspense fallback={<div>Loading...</div>}> - <SignInButton user={user} url={url} /> - </Suspense> + <SignInButton user={user} url={url} /> ... - <main> - <Outlet /> - </main> + <main> + <Suspense fallback={<div>Loading...</div>}> + <Outlet /> + </Suspense> + </main>📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b0951c495a916e9e13e96847777544ce88684d9f and 1608437ac672d866ef2146326ddc73b7cd213610.
📒 Files selected for processing (1)
examples/react/start-workos/src/routes/__root.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
examples/react/start-workos/src/routes/__root.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
examples/react/start-workos/src/routes/__root.tsx
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/start-workos/src/routes/__root.tsx
🧬 Code graph analysis (1)
examples/react/start-workos/src/routes/__root.tsx (1)
examples/react/start-workos/src/components/sign-in-button.tsx (1)
SignInButton(5-21)
⏰ 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). (1)
- GitHub Check: Test
🔇 Additional comments (4)
examples/react/start-workos/src/routes/__root.tsx (4)
5-7: Good server/client split on imports.Using server functions from
@workos/authkit-tanstack-react-startand the client provider from its/cliententry is correct for Start’s bundling model.
9-10: Import order fixed.app.css?urlnow precedes the type import, resolving the prior import/order lint complaint.
26-26: Stylesheet link wiring looks right.Referencing
appCssUrlvialinksensures SSR-safe stylesheet injection.
94-94: Good accessibility default.<html lang="en">is a solid baseline for a11y and SEO.@schiller-manuel It would be great to see this merged sooner rather than later, so developers have clarity on current best practices and are not confused by outdated docs.
This is now the preferred way of using WorkOS and is being actively developed by @nicknisi and the WorkOS team. On Dec 15 2025, related templates and examples repos from WorkOS were archived in favor of this SDK, and it also aligns with @convex-dev/workos-authkit.
Sign in to join this conversation.
Walkthrough#
The PR removes the repository's custom server-side AuthKit SSR implementation and replaces it with the official
@workos/authkit-tanstack-react-startintegration: deleted internal auth SSR modules, added middleware via a newstartInstance, updated routes/loaders to call library APIs, added a client demo route, CSS and Vite/type adjustments.Changes#
examples/react/start-workos/package.json,examples/react/start-workos/vite.config.ts@workos/authkit-tanstack-react-startdependency and reorderedpostcss; addedssr.noExternal: ['@radix-ui/themes']to Vite config.Deleted files:
examples/react/start-workos/src/authkit/serverFunctions.ts,examples/react/start-workos/src/authkit/ssr/config.ts,examples/react/start-workos/src/authkit/ssr/interfaces.ts,examples/react/start-workos/src/authkit/ssr/session.ts,examples/react/start-workos/src/authkit/ssr/utils.ts,examples/react/start-workos/src/authkit/ssr/workos.tsexamples/react/start-workos/src/start.tsstartInstanceexporting a TanStack Start instance configured withauthkitMiddleware()inrequestMiddleware.examples/react/start-workos/src/routes/__root.tsx,.../src/routes/index.tsx,.../src/routes/_authenticated.tsx,.../src/routes/_authenticated/account.tsx,.../src/routes/logout.tsx,.../src/routes/api/auth/callback.tsx@workos/authkit-tanstack-react-startAPIs (e.g.,getAuth,getSignInUrl,signOut,handleCallbackRoute); converted severalbeforeLoadusages toloaderand updated data shapes.examples/react/start-workos/src/routes/client.tsx,examples/react/start-workos/src/routeTree.gen.ts/clientfile route and UI demonstrating client-side hooks (useAuth,useAccessToken); injectedClientRouteinto generated route maps/types and updated start/type wiring to includestartInstance.getOptions.examples/react/start-workos/src/app.css,examples/react/start-workos/src/vite-env.d.tsapp.css; added Vite CSS URL module declaration and/// <reference types="vite/client" />invite-env.d.ts.examples/react/start-workos/src/routeTree.gen.ts/clientto unions, and extended@tanstack/react-startRegister config type to usestartInstance.getOptions.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs#
Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
@workos/authkit-tanstack-react-startSDK. The title accurately identifies which example is being updated (the WorkOS example) and the nature of the change (adopting the new AuthKit SDK), which aligns with the substantial refactoring shown in the file summaries—removing internal authentication modules and replacing them with imports from the new SDK package.✨ Finishing touches
🧪 Generate unit tests (beta)
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