
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@workos-inc/authkit-ssr
Advanced tools
> [!WARNING] >This is prerelease software. APIs may change without notice.
[!WARNING] This is prerelease software. APIs may change without notice.
A framework-agnostic authentication library for WorkOS with a modular adapter system for server-side rendered applications.
# Using npm
npm install @workos-inc/authkit-ssr
# Using pnpm
pnpm add @workos-inc/authkit-ssr
# Using yarn
yarn add @workos-inc/authkit-ssr
import { configure, createAuthKitFactory } from '@workos-inc/authkit-ssr';
configure({
clientId: 'your-client-id',
apiKey: 'your-workos-api-key',
redirectUri: 'https://yourdomain.com/auth/callback',
cookiePassword: 'must-be-at-least-32-characters-long-secret',
});
import { SessionStorage, createAuthKitFactory } from '@workos-inc/authkit-ssr';
// Create your framework-specific storage adapter
class MyFrameworkStorage implements SessionStorage<MyRequest, MyResponse> {
cookieName: string;
constructor(cookieName = 'wos-session') {
this.cookieName = cookieName;
}
async getSession(request: MyRequest): Promise<string | null> {
// Framework-specific implementation to get cookie
return getCookieFromRequest(request, this.cookieName);
}
async saveSession(response: MyResponse, sessionData: string): Promise<MyResponse> {
// Framework-specific implementation to set cookie
return setCookieOnResponse(response, this.cookieName, sessionData);
}
async clearSession(response: MyResponse): Promise<MyResponse> {
// Framework-specific implementation to clear cookie
return clearCookieOnResponse(response, this.cookieName);
}
}
// Create your AuthKit instance
const authKit = createAuthKitFactory<MyRequest, MyResponse>({
storage: new MyFrameworkStorage(),
});
// Validate a session
const { user, claims } = await authKit.withAuth(request);
// Generate an authorization URL
const authUrl = await authKit.getAuthorizationUrl({
returnPathname: '/dashboard',
});
// Refresh a session
const refreshResult = await authKit.refreshSession(session);
AuthKit SSR uses encrypted cookies to store session information. It handles:
The adapter pattern uses a storage interface to abstract framework-specific concepts:
interface SessionStorage<TRequest, TResponse> {
getSession(request: TRequest): Promise<string | null>;
saveSession(response: TResponse, sessionData: string): Promise<TResponse>;
clearSession(response: TResponse): Promise<TResponse>;
}
Each framework adapter implements this interface to handle its specific request/response objects.
AuthKit can be configured in multiple ways:
WORKOS_CLIENT_ID=your-client-id
WORKOS_API_KEY=your-api-key
WORKOS_REDIRECT_URI=https://yourdomain.com/auth/callback
WORKOS_COOKIE_PASSWORD=must-be-at-least-32-characters-long
import { configure } from '@workos-inc/authkit-ssr';
configure({
clientId: 'your-client-id',
apiKey: 'your-api-key',
redirectUri: 'https://yourdomain.com/auth/callback',
cookiePassword: 'must-be-at-least-32-characters-long',
cookieName: 'your-custom-cookie-name', // Default: 'wos-session'
cookieMaxAge: 60 * 60 * 24 * 30, // 30 days in seconds
cookieSameSite: 'lax', // 'strict', 'lax', or 'none'
});
configure(config): Set up AuthKit with your WorkOS configurationgetConfig(key): Get a specific configuration valuecreateAuthKitFactory(options): Create an instance of AuthKit for your frameworkwithAuth(request): Validate the current session and return user datagetAuthorizationUrl(options): Generate a WorkOS authorization URLgetSignInUrl(options): Generate a sign-in URLgetSignUpUrl(options): Generate a sign-up URLrefreshSession(session): Refresh an existing sessionsaveSession(response, sessionData): Save session data to a responsegetLogoutUrl(session, response, options): End a user sessionAuthKit uses iron-webcrypto for secure, encrypted cookies with the following security features:
MIT
FAQs
> [!WARNING] >This is prerelease software. APIs may change without notice.
The npm package @workos-inc/authkit-ssr receives a total of 2 weekly downloads. As such, @workos-inc/authkit-ssr popularity was classified as not popular.
We found that @workos-inc/authkit-ssr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.