Skip to main content
Version: v2

@friendlycaptcha/sdk > WidgetHandle

WidgetHandle class

This provides an API stub that provides the end-user JS API for a widget.

This class is only instantiated by the SDK - do not create a handle yourself.

Signature:

export declare class WidgetHandle 

Remarks

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the WidgetHandle class.

Properties

PropertyModifiersTypeDescription
idreadonlystringA random ID that uniquely identifies this widget in this session.
isDestroyedbooleanWhen this is true the widget has been destroyed and can no longer be used.
sitekey?readonlystring(Optional) The sitekey for this widget. It can not be changed after creation of the widget.
startModeStartMode

Methods

MethodModifiersDescription
addEventListener(type, listener, options)Shorthand for this.getElement().addEventListener (that is strictly typed in Typescript)
destroy()

Destroy the widget.

This removes the element that the widget was mounted to as well as the hidden frc-captcha-response form field.

getElement()The HTML element that contains the widget.
getResponse()The current response of the widget. This is the value that should be sent to the server and is embedded in HTML forms.
getState()The current state of the widget.
removeEventListener(type, listener, options)Shorthand for this.getElement().removeEventListener (that is strictly typed in Typescript)
reset(opts)

Reset the widget, removing any progress.

Optional argument: an object with the name of the trigger that caused the reset. You would usually keep this empty. This is the trigger field in the frc:widget.reset event, which defaults to root.

start()

Trigger the widget to start a challenge. The widget will start a challenge solving in the background.

* In interactive mode, the user will need to click the widget to complete the process. * In noninteractive mode, the widget will complete the process automatically.