Skip to content

Integrating with ReactJS

The official SDK replaces react-oidc-context with a drop-in API. Install once and you’re done — no JWKS wiring, no separate jwks-rsa dependency.

Terminal window
npm install @authaction/web-sdk
main.tsx
import { AuthActionProvider } from "@authaction/web-sdk/react";
<AuthActionProvider
domain="myapp.eu.authaction.com"
clientId="your-client-id"
redirectUri={`${window.location.origin}/`}
postLogoutRedirectUri={`${window.location.origin}/`}
authorizationParams={{ audience: "https://api.myapp.com" }}
>
<App />
</AuthActionProvider>;
App.tsx
import { useAuthAction } from "@authaction/web-sdk/react";
function App() {
const { isLoading, isAuthenticated, user, loginWithRedirect, logout } = useAuthAction();
if (isLoading) return <Spinner />;
if (!isAuthenticated) return <button onClick={() => loginWithRedirect()}>Login</button>;
return <button onClick={() => logout()}>Hello {user?.name}</button>;
}

Full SDK reference: github.com/authaction/authaction-web-sdk