npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

authjs-steam-provider

v1.0.0

Published

Steam OpenID provider for Auth.js v5 (NextAuth), edge-ready and typed.

Downloads

17

Readme

authjs-steam-provider

Auth.js v5 provider for Steam OpenID. Minimal, edge-friendly, and typed. It plugs directly into NextAuth/Auth.js and exchanges the Steam OpenID assertion for a session, then enriches the profile via Steam Web API.

• Provider ID: steam • Peer deps: next (>=13 <16), next-auth (>=5.0.0-beta.18 <6)


Installation

npm install authjs-steam-provider
# or
yarn add authjs-steam-provider

You also need a Steam Web API Key. Get it at: https://steamcommunity.com/dev/apikey


Requirements and Configuration

Set the following environment variables:

  • NEXTAUTH_URL: Your public app URL (e.g. https://example.com)
  • STEAM_API_KEY: Your Steam Web API key

Provider options (required):

  • clientSecret: The Steam Web API key
  • callbackUrl: Absolute callback base URL for your NextAuth callback route, e.g. ${NEXTAUTH_URL}/api/auth/callback

Notes:

  • The provider constructs openid.return_to as ${callbackUrl}/steam and validates the OpenID assertion against it.
  • Works on the Edge runtime (no Node-specific APIs).

Usage (Next.js App Router, Auth.js v5)

File: app/api/auth/[...nextauth]/route.ts

import NextAuth from "next-auth"
import SteamProvider from "authjs-steam-provider"

export const { handlers, auth } = NextAuth({
  providers: [
    // Important: pass the Request to the provider
    (req) =>
      SteamProvider(req, {
        clientSecret: process.env.STEAM_API_KEY!,
        callbackUrl: `${process.env.NEXTAUTH_URL}/api/auth/callback`,
      }),
  ],
})

export const GET = handlers.GET
export const POST = handlers.POST

Client-side sign-in:

import { signIn } from "next-auth/react"

// triggers the Steam OpenID flow
await signIn("steam")

Accessing the session:

import { auth } from "@/app/api/auth/[...nextauth]/route"

export default async function Page() {
  const session = await auth()
  // session.user has id, name, email (synthetic), image
  return <pre>{JSON.stringify(session, null, 2)}</pre>
}

API Reference

Default export

SteamProvider(req: Request, options: SteamProviderOptions): OAuthConfig<SteamProfile>
  • req: The Next.js Request of the current auth route handler.
  • options:
    • clientSecret: string — Steam Web API key.
    • callbackUrl: string | URL — Base callback URL (e.g. ${NEXTAUTH_URL}/api/auth/callback).
    • You may also pass standard OAuthUserConfig<SteamProfile> fields via options (as it extends Partial of it), if needed.

Profile mapping

profile(profile: SteamProfile) returns:

{
  id: profile.steamid,
  image: profile.avatarfull,
  email: `${profile.steamid}@steamcommunity.com`, // synthetic (Auth.js requires an email)
  name: profile.personaname,
}

Authorization flow

  • Initiates OpenID via https://steamcommunity.com/openid/login.
  • Validates assertion server-side with openid.mode=check_authentication.
  • Extracts steamId from the claimed identifier.
  • Fetches player summary using ISteamUser/GetPlayerSummaries with clientSecret and steamId.

Types

SteamProviderOptions (from src/types/steam.ts):

interface SteamProviderOptions {
  callbackUrl: string | URL
  clientSecret: string
}

SteamProfile is compatible with Steam Web API player summary, including at least:

interface SteamProfile {
  steamid: string
  personaname: string
  avatar: string
  avatarmedium: string
  avatarfull: string
  profileurl: string
  // …additional fields from Steam
}

Provider constants:

  • PROVIDER_ID = "steam"
  • PROVIDER_NAME = "Steam"
  • AUTHORIZATION_URL = "https://steamcommunity.com/openid/login"

Best Practices and Tips

  • Ensure NEXTAUTH_URL matches your deployed domain (including protocol).
  • callbackUrl must be absolute and point to your NextAuth callback base: ${NEXTAUTH_URL}/api/auth/callback.
  • Use a dedicated environment variable for STEAM_API_KEY; never commit it.
  • If you customize session callbacks, keep the user.id sourced from profile.steamid to maintain stable identity.
  • The email is synthetic to satisfy Auth.js serialization; don’t use it for outbound email.
  • Prefer running the auth route on Edge for lower latency; this provider is edge-safe.
  • Handle errors gracefully in UI; Steam may return non-OK responses if the user is private or API is down.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Links

  • Auth.js Docs (v5): https://authjs.dev
  • Issues / Contributing: https://github.com/goncalojbsousa/authjs-steam-provider/issues