Auth
BIAB provides a drop-in auth system for your externally-hosted site — sign-in, sign-up, password reset, and session management, all backed by WorkOS.
import { createAuthHandler } from '@biab-dev/sdk/next'
// Also available: @biab-dev/sdk/astro, @biab-dev/sdk/remix, etc.
export const { GET, POST } = createAuthHandler({
successUrl: '/dashboard',
callbackUrl: `${process.env.NEXT_PUBLIC_SITE_URL}/api/biab-auth/callback`,
})
Protect a route
import { getTenantSession } from '@biab-dev/sdk/next'
export default async function DashboardPage() {
const session = await getTenantSession()
if (!session) return <SignIn />
return <Dashboard user={session.user} />
}
React components
import { SignIn, SignUp, SignOut, useUser } from '@biab-dev/sdk/react'
function AuthButtons() {
const user = useUser()
if (user) return <SignOut />
return (
<>
<SignIn />
<SignUp mode="modal" />
</>
)
}
Programmatic auth
import { signIn, signUp, signOut, requestPasswordReset }
from '@biab-dev/sdk'
await signIn({ email: 'jane@example.com' })
await signUp({ email: 'jane@example.com', password: '…' })
await signOut()
await requestPasswordReset({ email: 'jane@example.com' })
Requires the site's auth callback URL to be registered as a WorkOS redirect URI in Settings → Integrations.