Skip to content

useConfig ​

Provides reactive access to the application's runtime configuration stored in Vuex — environment, app name, Inertia mode, and in-flight request tracking.

File: vue/src/js/hooks/useConfig.js


Usage ​

js
import { useConfig } from '@/hooks'

const {
  isHot,
  appName,
  appEnv,
  shouldUseInertia,
  isRequestInProgress,
  setRequestInProgress,
  increaseAxiosRequest,
  decreaseAxiosRequest
} = useConfig()
html
<v-progress-linear v-if="isRequestInProgress" indeterminate />
<span>{{ appName }} — {{ appEnv }}</span>

Returns ​

State ​

NameTypeDescription
isHotComputedRef<Boolean>true when the app is running in hot-reload (dev) mode
appNameComputedRef<String>Application name from store.state.config.app_name
appEnvComputedRef<String>Environment string ('local', 'production', etc.) from store.state.config.app_env
shouldUseInertiaComputedRef<Boolean>true when Inertia.js SPA navigation is enabled
isRequestInProgressComputedRef<Boolean>true when at least one axios request is currently in-flight

Methods ​

NameSignatureDescription
setRequestInProgress(value: Boolean) => voidDirectly set the in-progress flag
increaseAxiosRequest() => voidIncrement the in-flight request counter
decreaseAxiosRequest() => voidDecrement the in-flight request counter

Notes ​

  • isRequestInProgress is derived from a counter, not a boolean flag — increaseAxiosRequest / decreaseAxiosRequest allow multiple concurrent requests to be tracked correctly.
  • shouldUseInertia gates navigation calls: when true, use router.visit() instead of window.open().

See Also ​