# useAmbassadorCollection

**Category:** Common/Hooks

## API

### Overview

A React hook that initializes a collection state using an Ambassador SDK package.
The ambassador package should implement the [`crud.ts` module](https://bo.wix.com/wix-docs/rnd/platformization-guidelines/api-design-patterns#platformization-guidelines_api-design-patterns_auto-crud-sdk-generation-experimental). This is a higher-level alternative to [`useCollection`](./?path=/story/common-hooks--usecollection) that auto-generates `fetchData`, `queryName`, and `itemKey` from the Ambassador SDK.

```tsx
import { useAmbassadorCollection } from '@wix/patterns';
```

### Example

```tsx
import { useAmbassadorCollection, Table } from '@wix/patterns';
import { contacts } from '@wix/crm';

const state = useAmbassadorCollection({
  ambassador: contacts,
  transformPlatformizedQuery: (query) => query,
});

return (
   c.name },
    ]}
  />
);
```

### Returns

[CollectionState](./?path=/story/common-state--collectionstate)

### Props

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `ambassador` | `Required<Pick<AutoCrudHttp<T>, "fqdn" \| "queryEntities">>` | Yes | - | CRUD subpackage of a metro Ambassador package. |
| `transformPlatformizedQuery` | `TransformPlatformizedQuery` | No | - | A function to transform the cairo query to a PlatformizedQuery object (which will be used to fetch data from the server): - `platformizedQuery`: PlatformizedQuery - `wixPatternsQuery`: CursorQuery The function should return a PlatformizedQuery instance or a promise of PlatformizedQuery |
| `queryName` | `string` | No | `ambassador.fqdn` | The query name used for cache purposes. This should be a unique value per API endpoint. |

