Skip to content

Function: usePropsProxy()

ts
function usePropsProxy<Props>(
  props: Props,
  overrides: Record<string, any>,
  omit: keyof Props[],
): ComputedRef<{
  [key: string]: any;
}>;

Creates a computed proxy that unwraps reactive props and merges them with override values. Useful for creating a reactive object that combines component props with custom values, while optionally excluding specific prop keys.

Type Parameters

Type ParameterDescription
Props extends Record<string, any>The component props type

Parameters

ParameterTypeDefault valueDescription
propsPropsundefinedThe reactive props object (typically from setup function)
overridesRecord<string, any>{}Optional object with values to override or extend the props
omitkeyof Props[][]Optional array of prop keys to exclude from the result

Returns

ComputedRef<{ [key: string]: any; }>

A computed ref containing the merged unwrapped props and overrides (excluding omitted keys)

Example

typescript
const props = defineProps<{ name: string; age: number; internal: string }>();

// Basic usage with overrides
const propsProxy = usePropsProxy(props, { customField: "value" });
// propsProxy.value = { name: '...', age: 42, internal: '...', customField: 'value' }

// With omit to exclude specific props
const filteredProxy = usePropsProxy(props, { customField: "value" }, [
  "internal",
]);
// filteredProxy.value = { name: '...', age: 42, customField: 'value' }