Skip to content

⬅️ Back to Table of Contents

📄 index.ts

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 5
📊 Variables & Constants 2

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useSSRWidth/index.ts

📦 Imports

Name Source
App vue
InjectionKey vue
injectLocal @vueuse/shared
provideLocal @vueuse/shared
hasInjectionContext vue

Variables & Constants

Name Type Kind Value Exported
ssrWidthSymbol InjectionKey<number> const Symbol('vueuse-ssr-width') as InjectionKey<number | null>
ssrWidth any const hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null

Functions

useSSRWidth(): number

Code
export function useSSRWidth() {
  // Avoid injection warning outside of components
  const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null
  return typeof ssrWidth === 'number' ? ssrWidth : undefined
}
  • Return Type: number
  • Calls:
  • hasInjectionContext (from vue)
  • injectLocal (from @vueuse/shared)
  • Internal Comments:
    // Avoid injection warning outside of components (x2)
    

provideSSRWidth(width: number | null, app: App<unknown>): void

Code
export function provideSSRWidth(width: number | null, app?: App<unknown>) {
  if (app !== undefined) {
    app.provide(ssrWidthSymbol, width)
  }
  else {
    provideLocal(ssrWidthSymbol, width)
  }
}
  • Parameters:
  • width: number | null
  • app: App<unknown>
  • Return Type: void
  • Calls:
  • app.provide
  • provideLocal (from @vueuse/shared)