Package Exports
- better-auth-steam
- better-auth-steam/client
Readme
better-auth-steam
Steam OpenID 2.0 plugin for Better Auth.
It adds a Steam login flow via two endpoints:
GET /api/auth/steam/login?callbackURL=/...GET /api/auth/steam/callback
Install
pnpm add better-auth-steamServer usage
import { betterAuth } from 'better-auth/minimal';
import { steamOpenID } from 'better-auth-steam';
export const auth = betterAuth({
// ...your Better Auth config
plugins: [
steamOpenID({
apiKey: process.env.STEAM_API_KEY!
})
]
});Options
type SteamPluginOptions = {
apiKey: string;
syntheticEmailDomain?: string;
mapProfileToUser?: (profile: SteamPlayerSummary) => {
name?: string;
email?: string;
image?: string | null;
};
schema?: BetterAuthPluginDBSchema;
};apiKey: Steam Web API key from https://steamcommunity.com/dev/apikeysyntheticEmailDomain: used to generate fallback emails, defaults tosteam.localmapProfileToUser: optional mapping function for Steam profile fieldsschema: override or extend the plugin schema
Client plugin
import { createAuthClient } from 'better-auth/client';
import { steamOpenIDClient } from 'better-auth-steam/client';
export const authClient = createAuthClient({
plugins: [steamOpenIDClient()]
});Schema behavior
The plugin adds a nullable unique steamId field on the Better Auth user model.
account.providerId:steamaccount.accountId: SteamID64user.steamId: SteamID64
Security notes
- Callback and error callback redirects are normalized and restricted to the current app origin.
- OpenID assertions are validated against Steam using
check_authentication.
Development
pnpm install
pnpm run lint
pnpm run typecheck
pnpm run build