A client to fetch data from VTEX CMS.
npm install @vtex/client-cmsThis package is responsible for fetching data from VTEX CMS.
To install @vtex/client-cms in your project, just run:
```
npm instal @vtex/client-cms
To create a new ClientCMS instance you should use the ClientCMS class:
`javascript`
const client = new ClientCMS({
tenant: '',
builder: '',
workspace: '',
host: '',
});
Where tenant is your store's account name and workspace is the VTEX IO workspace being used. Usually you won't to set this option, being master the default. You can use builder to specify a different source of data on the CMS, using 'faststore' as default.
With the client instance you should use the main three methods to query data:
To gets ids from all Content Types.
`javascript`
const contentTypeIds = await client.getAllContentTypeIds();
To gets data from all pages of a given Content Type.
`javascript`
const paginatedCMSPages = await client.getCMSPagesByContentType(
'contentTypeId',
{
page: 1,
perPage: 3,
}
);
To gets all data from a given page.
`javascript``
const CMSPage = await client.getCMSPage({
contentType: '',
documentId: '',
versionId: '',
});