Skip to main content

Interface: LoginMiddleware

LoginMiddleware is the interface for creating middleware compatible with <Form> and the logIn() function of the useSlashID() hook.

@react/slashid middleware is a powerful API which provides you with a post-login lifecycle hook for modifying the user object or performing side-effects before the login operation completes. A LoginMiddleware is any function which accepts a LoginMiddlewareContext and returns Promise<User>.

During login, the login operation is blocked until all middlewares have resolved.

For a practical example see the defaultOrganization middleware.


import { LoginMiddleware } from '@slash/react'

const middleware: LoginMiddleware = (context) => {
// ...

return context.user


interface LoginMiddlewareContext {
user: User
sid: SlashID

type LoginMiddleware = (context: LoginMiddlewareContext) => Promise<User>