My Module
My new Nuxt module for doing amazing things.
Shared composables and utils, installed by @gluhar/app. Installs @nuxtjs/device.
useResponsive()
The one breakpoint composable for every gluhar project. It replaces the project-level useMobile copies.
For behaviour only — event handlers, GSAP/ScrollTrigger setup, measuring. Responsive layout is Tailwind variants in the template; never put a width flag in v-if / :class.
const { isMobileDevice, mounted, mobile, tablet, desktop, touch, up, down, between } =
useResponsive();
const nav = up("nav"); // any --breakpoint-* the project declares
onMounted(() => {
if (desktop.value) initParallax(); // already correct here
});
| Source | On the server | Safe in markup | |
|---|---|---|---|
isMobileDevice | user agent | real value | yes — but it's a device guess, not a width |
mobile tablet desktop wide touch tabletExact desktopExact up() down() between() | viewport width | false | no |
- Width flags stay
falsethrough the first hydration so server and client renders agree, then switch on in the composable's ownonMounted— before anyonMountedyou register after calling it. Components created after hydration get live values immediately. - Breakpoints are the project's
--breakpoint-*CSS values (read by@gluhar/theme), defaulting totablet768 /desktop1200 /wide2000. >=comparisons, like CSSmin-width:tabletandtablet:agree at every width, including exactly 768.mobile= belowtablet;touch= belowdesktop(a width, not touch capability).
Development
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release