Skip to content

feat[client-js]: Adds opt-in React Router loaders for @okta/okta-client-javascript - #321

Open
BenjaminTruong-okta wants to merge 2 commits into
masterfrom
feat/client-js-opt-in-support
Open

feat[client-js]: Adds opt-in React Router loaders for @okta/okta-client-javascript#321
BenjaminTruong-okta wants to merge 2 commits into
masterfrom
feat/client-js-opt-in-support

Conversation

@BenjaminTruong-okta

@BenjaminTruong-okta BenjaminTruong-okta commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds a @okta/okta-react/client-js subpath exporting createFetchLoader, createTokenLoader, and createLoginCallbackLoader - React Router v6.4+ data-router loader factories that wrap @okta/auth-foundation, @okta/oauth2-flows, and @okta/spa-platform (0.6.0 beta) as an alternative to the okta-auth-js-based API.

createLoginCallbackLoader resumes the auth code flow via AuthorizationCodeFlowOrchestrator.resumeFlow(), which exchanges the code and stores the resulting credential itself, then redirects to the original URI. This replaces the component for apps using the new SDK's data router.

The new peer SDKs are declared as optional peerDependencies so the default @okta/okta-react bundle has no dependency on them; a dedicated Rollup target and ESLint import-boundary rule keep the two bundles isolated from each other.

Jest's jsdom environment doesn't implement a spec-compliant Fetch API, which the data router's loader/redirect handling depends on - added undici (plus its Node-native web API polyfills) via a new setupFiles entry so the loader tests exercise real Request/Response objects.

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Adding Tests
  • Build related changes
  • CI related changes
  • Documentation changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Reviewers

…nt-javascript

Adds a `@okta/okta-react/client-js` subpath exporting createFetchLoader,
createTokenLoader, and createLoginCallbackLoader - React Router v6.4+
data-router loader factories that wrap @okta/auth-foundation,
@okta/oauth2-flows, and @okta/spa-platform (0.6.0 beta) as an alternative
to the okta-auth-js-based API.

createLoginCallbackLoader resumes the auth code flow via
AuthorizationCodeFlowOrchestrator.resumeFlow(), which exchanges the code
and stores the resulting credential itself, then redirects to the
original URI. This replaces the <LoginCallback /> component for apps
using the new SDK's data router.

The new peer SDKs are declared as optional peerDependencies so the
default @okta/okta-react bundle has no dependency on them; a dedicated
Rollup target and ESLint import-boundary rule keep the two bundles
isolated from each other.

Jest's jsdom environment doesn't implement a spec-compliant Fetch API,
which the data router's loader/redirect handling depends on - added
undici (plus its Node-native web API polyfills) via a new setupFiles
entry so the loader tests exercise real Request/Response objects.
Expands the client-js section to contrast the authState/React-context
model used elsewhere in this SDK with client-js's evaluate-at-point-of-use
approach, including a before/after example and concrete differences
around staleness, effect dependencies, bootstrapping, and subscriptions.

Also fixes the SDK construction example: FetchClient takes a
TokenOrchestrator as its first constructor argument, not a bare config
object, so tokenOrchestrator must be constructed first.
@BenjaminTruong-okta
BenjaminTruong-okta marked this pull request as ready for review August 12, 2026 23:58
@BenjaminTruong-okta
BenjaminTruong-okta force-pushed the feat/client-js-opt-in-support branch from 5fdc0a7 to 0aca968 Compare August 13, 2026 00:05
Base automatically changed from dependency-upgrades to master August 13, 2026 19:42
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.

1 participant