Function: useAddonConfig()
ts
function useAddonConfig<AddonOptions>(addonName): ComputedRef<
| ValaxyAddon<AddonOptions>
| undefined>;Defined in: packages/valaxy/client/config.ts:132
Get addon config from runtime config.
A generic, type-safe shortcut that every addon and theme can use instead of manually calling useRuntimeConfig() + computed(...) + type assertion.
Must be called inside <script setup> or a Vue lifecycle hook (same constraint as useRuntimeConfig()).
Type Parameters
AddonOptions
AddonOptions = Record<string, any>
Parameters
addonName
string
Returns
ComputedRef< | ValaxyAddon<AddonOptions> | undefined>
Examples
ts
// Inside an addon — replaces the boilerplate `useAddonXxxConfig()` pattern
import type { MyOptions } from '../types'
const config = useAddonConfig<MyOptions>('valaxy-addon-xxx')
config.value?.options // MyOptions | undefinedts
// Inside a theme component — no dynamic import needed
const algolia = useAddonConfig<AlgoliaSearchOptions>('valaxy-addon-algolia')
if (algolia.value) { /* addon is installed and configured */ }