Appearance
npm Package
Installation
bash
npm install intent-clickRequirements
- Node.js >= 18
- TypeScript >= 5.0 (if using TypeScript)
Exports
| Subpath | Description |
|---|---|
intent-click | Core types + vanilla namespace |
intent-click/core | Core engine (framework-agnostic) |
intent-click/vanilla | Vanilla JS API |
intent-click/react | React hook |
intent-click/vue | Vue composable + directive |
intent-click/svelte | Svelte action |
intent-click/solid | Solid primitive |
intent-click/angular | Angular directive |
Peer Dependencies
All framework packages are optional peer dependencies:
json
{
"peerDependencies": {
"react": ">=18.0.0",
"vue": ">=3.3.0",
"svelte": ">=4.0.0",
"solid-js": ">=1.7.0",
"@angular/core": ">=17.0.0"
},
"peerDependenciesMeta": {
"react": { "optional": true },
"vue": { "optional": true },
"svelte": { "optional": true },
"solid-js": { "optional": true },
"@angular/core": { "optional": true }
}
}Install only the framework you use.
Tree-Shaking
Package is fully tree-shakeable:
json
{
"sideEffects": false
}SSR (Next.js, Nuxt, SvelteKit)
Safe for server-side rendering:
typescript
// On server: getSnapshot() = null, subscribe() = no-op
// On client: hydrates and attaches listeners
import { createIntentClickStore } from 'intent-click/core';
const store = createIntentClickStore(element, callback);
const snapshot = store.getSnapshot(); // null on serverTroubleshooting
"Cannot find module 'intent-click/react'"
Install the peer dependency:
bash
npm install reactSSR errors
All APIs are SSR-safe. If you see errors, ensure:
- You're not reading
windowat module level - You're using
useEffect/onMountedfor initialization
Clicks not detected on mobile
Ensure:
- Element has
touch-action: manipulation(not required, but recommended) - You're not calling
preventDefault()onpointerdown/pointermove
TypeScript errors
Package ships with .d.ts files. If you see type errors:
- Ensure
strict: trueintsconfig.json - Run
npm run typecheck