Home > widget-integration > RecommendationModule > connectWidget
RecommendationModule.connectWidget() method
Connects the widget controller to the DOM element. Override this method to customize widget connection parameters or add pre-connection logic.
Signature:
protected connectWidget(widget: RecommendationWidgetController, block: AppBlock): Promise<void>;
Parameters
| 
 Parameter  | 
 Type  | 
 Description  | 
|---|---|---|
| 
 widget  | 
 The widget controller instance  | |
| 
 block  | 
 The AppBlock instance  | 
Returns:
Promise<void>
Promise that resolves when the widget connection is complete
Example
// Add custom widget connection parameters protected async connectWidget(widget, block) { const customParams = { widgetId: this.parseWidgetId(block.id), shopTheme: this.getShopTheme(), }; widget.connect(customParams, block.document); }