# ClientScriptInterface

> Defines the contract for registering client-side scripts for widgets and components.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › [client](/docs/api/yii/web/client/index.md) › ClientScriptInterface

| interface | `yii\web\client\ClientScriptInterface` |
| --- | --- |
| Since | 22.0 |
| Source | [`framework/web/client/ClientScriptInterface.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/client/ClientScriptInterface.php#L27) |

Defines the contract for registering client-side scripts for widgets and components.

Classes implementing this interface are responsible for providing client options and registering scripts in the
context of Yii2 widgets and views.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getClientOptions()`](#method-getClientOptions) abstract | Returns client-side options for the specified component. | `ClientScriptInterface` |
| [`register()`](#method-register) abstract | Registers the client script for the specified widget and view. | `ClientScriptInterface` |

## Method details

### getClientOptions() <span id="method-getClientOptions"></span>

```php
abstract public function getClientOptions(yii\web\client\T $object, array<string, mixed> $options = []): array<string, mixed>
```

Returns client-side options for the specified component.

This method is used to retrieve the options that will be passed to the client-side script.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$object` | `yii\web\client\T` | The object for which to get the client options. |
| `$options` | `array<string, mixed>` | Additional options that may influence the client options returned. |

**Returns**

`array<string, mixed>`: The client options for the widget or component.

### register() <span id="method-register"></span>

```php
abstract public function register(yii\web\client\T $object, yii\web\View $view, array<string, mixed> $options = []): void
```

Registers the client script for the specified widget and view.

This method is used to register the necessary client-side scripts for the widget in the given view.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$object` | `yii\web\client\T` | The object whose client script is to be registered. |
| `$view` | [`yii\web\View`](/docs/api/yii/web/view/index.md) | The view in which the client script should be registered. |
| `$options` | `array<string, mixed>` | Additional options that may influence the script registration process. |