BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fluid-functionalism/use-touch-primary

useTouchPrimary

fluid-functionalism/use-touch-primary
FreeHook

Detects touch-primary devices (coarse pointer + touch points), updating live on pointer-mode and media-query changes. Adapted from Lina (https://lina.sameer.sh).

Install it

npx shadcn@latest add https://fluidfunctionalism.com/r/use-touch-primary.json

Source

registry/default/hooks/use-touch-primary.tsxfluidfunctionalism.com/r/use-touch-primary.json
1"use client";
2
3// Adapted from Lina by SameerJS6 (https://lina.sameer.sh) — use-has-primary-touch.
4// Detects touch-primary devices (coarse pointer + touch points), updating live
5// on pointer-mode and media-query changes. Returns false on the server and the
6// first client render, so the non-touch branch is the hydration-stable default.
7
8import { useEffect, useState } from "react";
9
10export function useTouchPrimary() {
11 const [isTouchPrimary, setIsTouchPrimary] = useState(false);
12
13 useEffect(() => {
14 if (typeof window === "undefined") return;
15
16 const controller = new AbortController();
17 const { signal } = controller;
18
19 const handleTouch = () => {
20 const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
21 const prefersTouch = window.matchMedia("(pointer: coarse)").matches;
22 setIsTouchPrimary(hasTouch && prefersTouch);
23 };
24
25 const mq = window.matchMedia("(pointer: coarse)");
26 mq.addEventListener("change", handleTouch, { signal });
27 window.addEventListener("pointerdown", handleTouch, { signal });
28
29 handleTouch();
30
31 return () => controller.abort();
32 }, []);
33
34 return isTouchPrimary;
35}

Files it writes

  • registry/default/hooks/use-touch-primary.tsx

Facts

Registry
fluid-functionalism
Type
registry:hook
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

fluidfunctionalism.com mickadesign/fluid-functionalism on GitHub Raw registry item This item as JSON

More from fluid-functionalism

All 53 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
useMergeSplitBlocksuse-merge-splitfluid-functionalismHooksFreeno deps
useProximityHoveruse-proximity-hoverfluid-functionalismHooksFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex