Skip to content

remix/middleware/auth · Function

View Source

requireAuth

Summary

Enforces that auth() has already resolved a successful auth state for the current request.

Signature

function requireAuth<identity>(
  options: RequireAuthOptions,
): Middleware<{
  key: { defaultValue?: AuthState<unknown> }
  property: 'auth'
  value: GoodAuth<identity>
}>

Parameters

options

Failure handling options for unauthenticated requests.

Returns

Middleware that allows authenticated requests through, rejects anonymous ones, and narrows auth state on request context.