- Client registration (static trusted clients and dynamic registration)
- Authorization Code Flow
- Refresh token support
- OAuth consent screens (with bypass support for trusted apps)
- UserInfo endpoint
- JWKS endpoint integration via the JWT plugin
- Custom claims
Installation
1
Add the plugin to your auth config
auth.ts
2
Migrate the database
3
Add the client plugin
auth-client.ts
Registering clients
Dynamic registration
Clients can register via the/oauth2/register endpoint (RFC 7591):
Trusted clients (static configuration)
For first-party applications, configure trusted clients directly. They bypass database lookups and can skip the consent screen:auth.ts
OIDC endpoints
The plugin exposes these standard OIDC endpoints:UserInfo endpoint
The UserInfo endpoint returns claims based on the granted scopes:
Server-side:
Custom claims
auth.ts
Consent screen
By default, Better Auth shows a built-in consent screen. Customize it with aconsentPage path:
auth.ts
consent_code, client_id, and scope query parameters. After the user consents, call:
Trusted clients with
skipConsent: true bypass the consent screen entirely.Handling login
When users are not signed in and reach the authorization endpoint, they are redirected tologinPage. After a new session is created, the plugin automatically continues the authorization flow.
auth.ts
JWKS integration
Combine with the JWT plugin for asymmetric ID token signing:auth.ts
When
useJWTPlugin is false (default), ID tokens are signed with HMAC-SHA256 using the application secret.Customize OIDC metadata
auth.ts