useT3Api

This composable provides useful methods to use TYPO3 Api Client

Type

export const useT3Api = (
  path?: string,
  options?: FetchOptions<'json'>
): {
  /**
   * TYPO3 Page Data
   */
  pageData: Ref<T3Page>
  /**
   * TYPO3 Initial Data
   */
  initialData: Ref<T3InitialData>
  /**
   * Sharable $fetch client for TYPO3 API
   */
  $fetch: T3Api['$fetch']
  /**
   * Get TYPO3 Page data
   */
  getPage(path: string, options?: FetchOptions): Promise<T3Page>
  /**
   * Get TYPO3 Initial data
   */
  getInitialData(path?: string, options?: FetchOptions): Promise<T3InitialData>
  /**
   * Set API Headers
   */
  setHeaders(headers: Record<string, string>): void
  /**
   * Set API Clinet global options
   */
  setOptions<T extends keyof FetchOptions<'json'>>(key: T, value:FetchOptions<'json'>[T]): void
}

Example

<script setup lang="ts">
const { initialData } = useT3Api()
const navigation = computed(() => {
  return initialData.value?.navigation
})
</script>
Please be aware, the @t3headless/nuxt-typo3 is available as Early Access Program and API might change.
Table of Contents