Skip to content

withActiveParams @vuqs/core/modules ​

Derives which params are explicitly present and different from their composed defaults.

Usage ​

ts
import { codecs, useQueryStates } from '@vuqs/core'
import { withActiveParams } from '@vuqs/core/modules'

const query = useQueryStates({ q: codecs.string, page: codecs.integer })
  .use(withActiveParams({ exclude: ['page'] }))

query.activeCount.value
query.isActive('q')

Type ​

ts
import type { QueryModuleFactory } from '@vuqs/core'

declare const withActiveParams: QueryModuleFactory<
  'vuqs:active-params',
  typeof import('@vuqs/core/modules').withActiveParams.definition
>

QueryModuleFactory is exported from @vuqs/core. Its second type parameter preserves the module's setup definitions. See Factory call forms for adaptive, schema, param, and path calls.

Parameters ​

OptionTypeDefaultBehavior
excludereadonly (keyof TSchema & string)[][]Removes params from every grouped view. Captured when the module is composed.

The single-param form takes no options. Schema keys are inferred when the factory is called inline in .use().

Return value ​

A module contributing ActiveParamsStatesApi<TSchema> to a group or ActiveParamsStateApi to one param.

Grouped memberTypeBehavior
activeKeysComputedRef<readonly (keyof TSchema & string)[]>Active keys in schema order.
activeCountComputedRef<number>Count of active params.
hasActiveComputedRef<boolean>Whether a param is active.
isActive(key: keyof TSchema & string) => booleanReads the same reactive source as the aggregate views.

The single API exposes isActive: ComputedRef<boolean>. A param is active when an explicit value survives the read pipeline and differs from its composed default according to its equality function, compared without filling omitted children. Optimistic writes and changes to default layers update the result.

Call grouped isActive(key) in a template, computed, or effect when the result must track changes.

ActiveParamsOptions ​

ts
interface ActiveParamsOptions<TSchema extends QueryStateSchema> {
  exclude?: readonly (keyof TSchema & string)[]
}

ActiveParamsStatesApi ​

ts
interface ActiveParamsStatesApi<TSchema extends QueryStateSchema> {
  activeKeys: ComputedRef<readonly (keyof TSchema & string)[]>
  activeCount: ComputedRef<number>
  hasActive: ComputedRef<boolean>
  isActive: (key: keyof TSchema & string) => boolean
}

ActiveParamsStateApi ​

ts
interface ActiveParamsStateApi {
  isActive: ComputedRef<boolean>
}

Active params.

Released under the MIT License. Inspired by nuqs.