---
title: "useFetchComponentMeta"
description: "Read the component metadata generated by nuxt-component-meta, including the types and descriptions of props, slots and events. ComponentProps and the other component docs components are built on it; call it directly to render your own API tables. Available only with component docs enabled."
canonical_url: "https://docs.mhaibaraai.cn/en/docs/reference/composables/use-fetch-component-meta"
---
# useFetchComponentMeta

> Read the component metadata generated by nuxt-component-meta, including the types and descriptions of props, slots and events. ComponentProps and the other component docs components are built on it; call it directly to render your own API tables. Available only with component docs enabled.

`useFetchComponentMeta()` requests `/api/component-meta/{name}.json` and returns the result of `useAsyncData`. During server rendering the endpoint is added to the prerender list, and client navigation reuses the payload instead of requesting again.

> [!WARNING]
> 
> Set 
> 
> movkNuxtDocs.componentDocs: true
> 
>  in 
> 
> nuxt.config
> 
>  and install 
> 
> nuxt-component-meta
> 
> , 
> 
> vue-component-meta
> 
>  and 
> 
> prettier
> 
> , see 
> 
> Feature Flags
> 
> . When disabled, the function is not auto-imported.

## Usage

```vue
<script setup lang="ts">
const { data } = await useFetchComponentMeta('MyButton')
</script>

<template>
  <ul>
    <li v-for="prop in data?.meta?.props" :key="prop.name">
      <code>{{ prop.name }}</code>: {{ prop.type }}
    </li>
  </ul>
</template>
```

## Signature

```ts
function useFetchComponentMeta(name: string): AsyncData<Partial<ComponentMetaData> | undefined, NuxtError | undefined>

interface ComponentMetaData {
  meta: ComponentMeta // from vue-component-meta
}
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `name` | `string` | PascalCase component name, as registered by `nuxt-component-meta` |

## Return Value

The result of `useAsyncData`; the commonly used fields are:

| Name | Type | Description |
| --- | --- | --- |
| `data` | `Ref<Partial<ComponentMetaData> \| undefined>` | `data.meta` holds `props`, `slots`, `events`, `exposed` and more; an empty object when the component is missing or the request fails |
| `status` | `Ref<AsyncDataRequestStatus>` | Request status |
| `refresh` | `() => Promise<void>` | Request again |

## Notes

- On the client the call is lazy, so `data` can be empty on first render; guard against it in templates.
- Only the layer's own docs components are scanned by default; add your components to `componentMeta.include`, see [ComponentProps](https://docs.mhaibaraai.cn/en/docs/components/component-props).

## Related

- [ComponentProps](https://docs.mhaibaraai.cn/en/docs/components/component-props)
- [ComponentSlots](https://docs.mhaibaraai.cn/en/docs/components/component-slots)
- [ComponentEmits](https://docs.mhaibaraai.cn/en/docs/components/component-emits)

## Changelog

See commit history for [layer/modules/component-docs/runtime/composables/useFetchComponentMeta.ts](https://github.com/mhaibaraai/movk-nuxt-docs/commits/main/layer/modules/component-docs/runtime/composables/useFetchComponentMeta.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-nuxt-docs/blob/main/layer/modules/component-docs/runtime/composables/useFetchComponentMeta.ts)


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.cn/sitemap.md) for all pages.
