Skip to content

⬅️ Back to Table of Contents

📄 useSSRWidth

📊 Analysis Summary

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

📚 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>

Functions

useSSRWidth(): number

Returns: number

Calls:

  • hasInjectionContext (from vue)
  • injectLocal (from @vueuse/shared)

Internal Comments:

// Avoid injection warning outside of components (x2)

Code
export function useSSRWidth() {
  // Avoid injection warning outside of components
  const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null
  return typeof ssrWidth === 'number' ? ssrWidth : undefined
}

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

Parameters:

  • width number | null
  • app App<unknown>

Returns: void

Calls:

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

Generated by Syntax Scribe