VueScreen is a JavaScript library for Vue 3 that provides reactive access to window dimensions, media query states, and device orientation. It enables developers to easily integrate dynamic screen size information and breakpoint detection into their Vue applications. The current stable version is 2.4.2, and the project demonstrates an active release cadence with regular minor and patch updates, indicating ongoing maintenance and feature development. Key differentiators include its debounced reactive screen size updates, comprehensive media query state tracking, touch screen detection, and out-of-the-box support for popular UI framework breakpoints like Tailwind, Bootstrap, Bulma, Foundation, Materialize, and Semantic UI. It is also designed to be compatible with Server-Side Rendering (SSR) environments. Version 2.x of `vue-screen` specifically targets Vue 3 applications, with previous versions (v1.x) supporting Vue 2.
npm install vue-screenVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `vue-screen` with the Composition API to access reactive screen dimensions and grid breakpoints, and how to install it as a global plugin.
For Vue 2 projects, install `vue-screen@1`. For Vue 3 projects, ensure your `vue` peer dependency is `^3.0.0` and that you are using the v2 API.
Refer to the official upgrading guide in the documentation (https://reegodev.github.io/vue-screen/guide/upgrading) for detailed migration steps.
Ensure `const screen = useScreen()` and `const grid = useGrid()` are placed directly inside your component's `setup()` method or a custom composable.
When installing the plugin, specify the exact configuration string: `createApp().use(VueScreen, 'bootstrap-v5')` or `useGrid('bootstrap-v5')` if a specific version endpoint is provided.Ensure the plugin is globally installed: `createApp(App).use(VueScreen, 'bootstrap').mount('#app')`.Move the calls to `useScreen()` and `useGrid()` inside the `setup()` function of your Vue component.
Extend Vue's `ComponentCustomProperties` interface in a declaration file (e.g., `shims-vue.d.ts`):
```typescript
import '@vue/runtime-core';
import type { Screen, Grid } from 'vue-screen';
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$screen: Screen;
$grid: Grid;
}
}
```