# useAddOns

A custom React hook that retrieves the AddOnContext, throwing an error if used outside an AddOnProvider.

## Installation

```tsx
import { useAddOns } from 'uxp/components';
```

## Signature

```tsx
function useAddOns(): AddOnContextType
```

## Examples

```tsx
const MyComponent = () => {
  const { addOns, isAddOn } = useAddOns();
  return (
    <div>
      {addOns.map(addOn => (
        <p key={addOn.id}>{addOn.title}: {isAddOn(addOn.id) ? 'Add-On' : 'Not an Add-On'}</p>
      ))}
    </div>
  );
};
```

```tsx
const MyComponent = () => {
  const { getAddOnDetails, getThunmbNailImagePath } = useAddOns();
  const addOn = getAddOnDetails('module-1');
  return (
    <div>
      {addOn && (
        <div>
          <h2>{addOn.title}</h2>
          <img src={getThunmbNailImagePath('module-1')} alt={addOn.title} />
        </div>
      )}
    </div>
  );
};
```

## Related Types

* [AddOnContextType](https://help.iviva.com/uxp/v5/additional-resources/types/addoncontexttype)
* [IAddOn](https://help.iviva.com/uxp/v5/additional-resources/types/iaddon)
* [IInstalledAddOn](https://help.iviva.com/uxp/v5/additional-resources/types/iinstalledaddon)
* [IWidget](https://help.iviva.com/uxp/v5/additional-resources/types/iwidget)
* [IWidgetConfigs](https://help.iviva.com/uxp/v5/additional-resources/types/iwidgetconfigs)
* [DynamicFormFieldProps](https://help.iviva.com/uxp/v5/additional-resources/types/dynamicformfieldprops)
* [FormValue](https://help.iviva.com/uxp/v5/additional-resources/types/formvalue)
* [IFormData](https://help.iviva.com/uxp/v5/additional-resources/types/iformdata)
* [CustomValidateResponse](https://help.iviva.com/uxp/v5/additional-resources/types/customvalidateresponse)
* [FormSectionProps](https://help.iviva.com/uxp/v5/additional-resources/types/formsectionprops)
* [IConfigPanelProps](https://help.iviva.com/uxp/v5/additional-resources/types/iconfigpanelprops)
* [IContextProvider](https://help.iviva.com/uxp/v5/additional-resources/types/icontextprovider)
* [IPartialContextProvider](https://help.iviva.com/uxp/v5/additional-resources/types/ipartialcontextprovider)
* [Language](https://help.iviva.com/uxp/v5/additional-resources/types/language)
* [ICustomThemes](https://help.iviva.com/uxp/v5/additional-resources/types/icustomthemes)
* [IThemeProps](https://help.iviva.com/uxp/v5/additional-resources/types/ithemeprops)
* [ThemeType](https://help.iviva.com/uxp/v5/additional-resources/types/themetype)
* [UserDetails](https://help.iviva.com/uxp/v5/additional-resources/types/userdetails)
* [NavigationLink](https://help.iviva.com/uxp/v5/additional-resources/types/navigationlink)
* [Routes](https://help.iviva.com/uxp/v5/additional-resources/types/routes)
* [ConfiguredPage](https://help.iviva.com/uxp/v5/additional-resources/types/configuredpage)
* [ComponentType](https://help.iviva.com/uxp/v5/additional-resources/types/componenttype)
* [IUXPFunctions](https://help.iviva.com/uxp/v5/additional-resources/types/iuxpfunctions)
* [ViewOverride](https://help.iviva.com/uxp/v5/additional-resources/types/viewoverride)
* [Environment](https://help.iviva.com/uxp/v5/additional-resources/types/environment)
* [ExecutionOptions](https://help.iviva.com/uxp/v5/additional-resources/types/executionoptions)
* [CachingOptions](https://help.iviva.com/uxp/v5/additional-resources/types/cachingoptions)
* [IDataFunction](https://help.iviva.com/uxp/v5/additional-resources/types/idatafunction)
* [QueryParams](https://help.iviva.com/uxp/v5/additional-resources/types/queryparams)
* [ExecutionResult](https://help.iviva.com/uxp/v5/additional-resources/types/executionresult)
* [ExecuteMicroserviceConfig](https://help.iviva.com/uxp/v5/additional-resources/types/executemicroserviceconfig)
* [ExecuteConfigBase](https://help.iviva.com/uxp/v5/additional-resources/types/executeconfigbase)
* [LucyQueryResult](https://help.iviva.com/uxp/v5/additional-resources/types/lucyqueryresult)
* [IWidgetPreloader](https://help.iviva.com/uxp/v5/additional-resources/types/iwidgetpreloader)
