Skip to content

npm Package

Installation

bash
npm install intent-click

Requirements

  • Node.js >= 18
  • TypeScript >= 5.0 (if using TypeScript)

Exports

SubpathDescription
intent-clickCore types + vanilla namespace
intent-click/coreCore engine (framework-agnostic)
intent-click/vanillaVanilla JS API
intent-click/reactReact hook
intent-click/vueVue composable + directive
intent-click/svelteSvelte action
intent-click/solidSolid primitive
intent-click/angularAngular 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 server

Troubleshooting

"Cannot find module 'intent-click/react'"

Install the peer dependency:

bash
npm install react

SSR errors

All APIs are SSR-safe. If you see errors, ensure:

  1. You're not reading window at module level
  2. You're using useEffect / onMounted for initialization

Clicks not detected on mobile

Ensure:

  1. Element has touch-action: manipulation (not required, but recommended)
  2. You're not calling preventDefault() on pointerdown / pointermove

TypeScript errors

Package ships with .d.ts files. If you see type errors:

  1. Ensure strict: true in tsconfig.json
  2. Run npm run typecheck