Skip to main content
Callbacks are optional functions that allow you to take actions in your app or send logs to your backend based on where your user is in the authentication flow. Listeners can be passed in via the callbacks object in config, or by attaching to the custom element via addEventListener. If using addEventListener, the event names are stytch-event and stytch-error. To avoid conflicting with native DOM event properties, type and data values are storied in stytchEventType and stytchEventData properties.

onEvent

A function that is called when the Stytch client makes a request. The function expects an argument of an event object, and the event object has type and data objects.

onError

A function that is called when an error occurs. The function expects an argument of an StytchError object, and the StytchError object has a message property.