Skip to main content
Version: v4





The WorkOS Provider comes with a set of default options:

You can override any of the options to suit your own use case.


import WorkOSProvider from "next-auth/providers/workos";
providers: [
clientId: process.env.WORKOS_CLIENT_ID,
clientSecret: process.env.WORKOS_API_KEY,

WorkOS is not an identity provider itself, but, rather, a bridge to multiple single sign-on (SSO) providers. As a result, we need to make some additional changes to authenticate users using WorkOS.

In order to sign a user in using WorkOS, we need to specify which WorkOS Connection to use. A common way to do this is to collect the user's email address and extract the domain.

This can be done using a custom login page.

To add a custom login page, you can use the pages option:

pages: {
signIn: "/auth/signin",

We can then add a custom login page that displays an input where the user can enter their email address. We then extract the domain from the user's email address and pass it to the authorizationParams parameter on the signIn function:

import { useState } from "react"
import { getProviders, signIn } from "next-auth/react"

export default function SignIn({ providers }) {
const [email, setEmail] = useState("")

return (
{Object.values(providers).map((provider) => {
if ( === "workos") {
return (
<div key={}>
onChange={(event) => setEmail(}
onClick={() =>
signIn(, undefined, {
domain: email.split("@")[1],
Sign in with SSO

return (
<div key={}>
<button onClick={() => signIn(}>
Sign in with {}

export async function getServerSideProps(context) {
const providers = await getProviders()
return {
props: { providers },