Skip to content

oidc-js

Zero-dependency OIDC client for JavaScript & TypeScript.

oidc-js is an OpenID Connect client library for JavaScript and TypeScript. It handles the full OIDC lifecycle — discovery, PKCE, token exchange, refresh, userinfo, and logout — with zero runtime dependencies and a pure-functional core that works in any JS runtime.

The library follows a functional core, imperative shell architecture: the core package (oidc-js-core) contains only pure functions that build requests and parse responses. Framework adapters compose these functions with their own HTTP and storage layers.

Terminal window
npm install oidc-js-react
import { AuthProvider } from "oidc-js-react";
const config = {
issuer: "https://auth.example.com",
clientId: "my-app",
redirectUri: "http://localhost:3000/callback",
scopes: ["openid", "profile", "email"],
};
function App() {
return (
<AuthProvider config={config}>
<MyApp />
</AuthProvider>
);
}

Zero Dependencies

No runtime dependencies in the core package. Only the Web Crypto API. Works in browsers, Node.js, Deno, Bun, and Cloudflare Workers.

Pure Functional Core

Every core function takes data in and returns data out. No fetch, no storage, no side effects. Fully testable without mocks.

7 Framework Adapters

First-class support for React, Vue, Svelte, Angular, Solid, Preact, and Lit. Each adapter wraps the core in framework-native patterns.

PKCE by Default

Authorization Code Flow with Proof Key for Code Exchange (RFC 7636). No implicit flow, no client secrets in the browser.

Automatic Token Refresh

Auth guards detect expired tokens and silently refresh them using the refresh token. If the refresh fails, they redirect to login.

Contract-Tested

End-to-end Playwright tests against a real OIDC provider verify every flow: login, logout, refresh, deep linking, error handling, and security.

PackageDescriptionStatus
oidc-js-corePure functions, no IOStable
oidc-jsBrowser client (core + fetch + sessionStorage)Stable
oidc-js-reactReact context, hooks, and guardsStable
oidc-js-vueVue plugin, composables, and navigation guardStable
oidc-js-svelteSvelte context and componentsStable
oidc-js-angularAngular service, DI, and route guardStable
oidc-js-solidSolidJS signals, context, and componentsStable
oidc-js-preactPreact hooks and componentsStable
oidc-js-litLit reactive controllersStable