Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SteamStrategy
✓ import { SteamStrategy } from 'remix-auth-steam';
✗ const SteamStrategy = require('remix-auth-steam').SteamStrategy;
Package primarily designed for ESM usage with TypeScript.
SteamStrategyVerifyParams
✓ import type { SteamStrategyVerifyParams } from 'remix-auth-steam';
✗ import { SteamStrategyVerifyParams } from 'remix-auth-steam';
Import as a type (`import type`) for clearer separation and to avoid bundling unnecessary runtime code.
authenticator
✓ import { authenticator } from '~/services/auth.server';
This is a common pattern where `authenticator` is an instantiated object exported from a user-defined server module, not directly from `remix-auth-steam`.
This quickstart demonstrates a complete Steam authentication flow in a Remix application, including session management, strategy configuration, and protected routes. It shows how to initialize the `SteamStrategy`, handle Steam callbacks, and display user authentication status.
import { createCookieSessionStorage, redirect } from "@remix-run/node";
import type { LoaderFunction, ActionFunction } from "@remix-run/node";
import { Authenticator } from "remix-auth";
import { SteamStrategy, SteamStrategyVerifyParams } from "remix-auth-steam";
import { useLoaderData, Form, Link } from "@remix-run/react";
import React from "react";
// app/services/session.server.ts
// Helper to calculate cookie expiration
const calculateExpirationDate = (days: number) => {
const expDate = new Date();
expDate.setDate(expDate.getDate() + days);
return expDate;
};
// Session storage setup
export let sessionStorage = createCookieSessionStorage({
cookie: {
name: "_session",
sameSite: "lax",
path: "/",
httpOnly: true,
secrets: [process.env.SESSION_SECRET ?? "super-secret-dev-key"], // IMPORTANT: Use a strong, production secret from environment variables
secure: process.env.NODE_ENV === "production",
expires: calculateExpirationDate(7),
},
});
export let { getSession, commitSession, destroySession } = sessionStorage;
// app/services/auth.server.ts
// Define the User type based on SteamStrategyVerifyParams
export type User = SteamStrategyVerifyParams;
// Create an Authenticator instance
export let authenticator = new Authenticator<User>(sessionStorage);
// Register the SteamStrategy
authenticator.use(
new SteamStrategy(
{
returnURL: "http://localhost:3000/auth/steam/callback",
apiKey: process.env.STEAM_API_KEY ?? "YOUR_STEAM_API_KEY", // IMPORTANT: Get your API key from https://steamcommunity.com/dev/apikey
},
// The verify callback: here you can perform additional checks or database operations
async (user) => {
// For this example, we simply return the user data provided by Steam
console.log("Steam User Authenticated:", user.nickname, user.steamid);
return user;
}
),
"steam" // The name of the strategy to be used in authenticate calls
);
// app/routes/auth/steam.tsx
// This route initiates the Steam authentication flow
export let loader: LoaderFunction = async ({ request }) => {
return authenticator.authenticate("steam", request);
};
// app/routes/auth/steam/callback.tsx
// This route handles the callback from Steam after authentication
export let loader: LoaderFunction = ({ request }) => {
return authenticator.authenticate("steam", request, {
successRedirect: "/", // Redirect to home on success
failureRedirect: "/login", // Redirect to login on failure
});
};
// app/routes/login.tsx
export default function Login() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Login</h1>
<p>You need to log in to access this page.</p>
<Link to="/auth/steam">
<button>Login with Steam</button>
</Link>
</div>
);
}
// app/routes/index.tsx
export let loader: LoaderFunction = async ({ request }) => {
// Check if the user is authenticated
const user = await authenticator.isAuthenticated(request);
return user;
};
export default function Index() {
const user = useLoaderData<User | null>();
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
{user ? (
<>
<h1>Welcome, {user.nickname}!</h1>
<p>Your SteamID: {user.steamid}</p>
<Form action="/logout" method="post">
<button type="submit">Logout</button>
</Form>
</>
) : (
<>
<h1>Not Authenticated</h1>
<p>
<Link to="/login">Login with Steam</Link>
</p>
</>
)}
</div>
);
}
// app/routes/logout.tsx
export let action: ActionFunction = async ({ request }) => {
// Destroy the session and redirect to the login page
await authenticator.logout(request, { redirectTo: "/login" });
return redirect("/login");
};
Errors
Common errors & fixes
Error: Authenticate method missing 'strategy' argument.
The `authenticator.authenticate` method was called without specifying the strategy name (e.g., 'steam').
fixEnsure you pass the strategy name as the first argument: `authenticator.authenticate('steam', request, { ... })`. OpenID authentication failed: Missing realm parameter.
Steam OpenID requires a `realm` parameter, which is typically derived from your `returnURL`. Older versions or misconfigurations might lead to this error.
fixUpdate to at least `remix-auth-steam@1.0.4` which fixed realm passing. Ensure your `returnURL` is correctly formatted and accessible from Steam.
ReferenceError: authenticator is not defined
The `authenticator` instance was not correctly imported or instantiated in the server-side module where it's being used (e.g., `app/routes/auth/steam.tsx`).
fixVerify that `authenticator` is properly initialized in `app/services/auth.server.ts` and then correctly imported into your routes: `import { authenticator } from '~/services/auth.server';`. Error: Could not retrieve Steam API Key. Please provide one.
The `apiKey` option was either omitted or provided with an invalid or empty string during `SteamStrategy` instantiation.
fixProvide a valid Steam API key obtained from `https://steamcommunity.com/dev/apikey` as the `apiKey` option to the `SteamStrategy` constructor, preferably via environment variables: `apiKey: process.env.STEAM_API_KEY`.
Audit
Dependencies
remix-authrequiredCore authentication library for which this is a strategy.
@remix-run/server-runtimerequiredPeer dependency required by Remix applications for server-side utilities like `LoaderFunction` and `createCookieSessionStorage`.