{"_id":"@akson/cortex-landing-hooks","_rev":"4-d32542378f1acc06166bd6218591d08c","name":"@akson/cortex-landing-hooks","dist-tags":{"latest":"0.4.1"},"versions":{"0.3.0":{"name":"@akson/cortex-landing-hooks","version":"0.3.0","keywords":["akson","landing","react-hooks","device-detection","api-calls","form-submission","analytics","performance","image-preloader"],"author":{"name":"MyArmy","email":"contact@myarmy.ch"},"license":"MIT","_id":"@akson/cortex-landing-hooks@0.3.0","maintainers":[{"name":"antoineschaller","email":"antoine.schaller@akson.ch"}],"homepage":"https://github.com/antoineschaller/myarmy/tree/main/packages/@akson/cortex-landing-hooks","bugs":{"url":"https://github.com/antoineschaller/myarmy/issues"},"dist":{"shasum":"74f0bf435b545cb4d83a513fce158d5a5ca18bed","tarball":"https://registry.npmjs.org/@akson/cortex-landing-hooks/-/cortex-landing-hooks-0.3.0.tgz","fileCount":2,"integrity":"sha512-UXORfXHyCvJV5zsdlc+k7qjkQOXl9oHQdl/sC3IZI1T2ydND5d2nJDWeYtrSZH9viL9TgugHYbSmvyXfwtePOA==","signatures":[{"sig":"MEUCIQD5iaPZoMiibWzJnHNHV1QB+fFns+JCAIdZFG5Mx2Br/gIgRS0/Sgc28yFnd22dCylHm9j3R2kBDM2LEwrbk9oouJU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10580},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./data":{"types":"./dist/data/index.d.ts","import":"./dist/data/index.mjs","require":"./dist/data/index.js"},"./forms":{"types":"./dist/forms/index.d.ts","import":"./dist/forms/index.mjs","require":"./dist/forms/index.js"},"./device":{"types":"./dist/device/index.d.ts","import":"./dist/device/index.mjs","require":"./dist/device/index.js"},"./analytics":{"types":"./dist/analytics/index.d.ts","import":"./dist/analytics/index.mjs","require":"./dist/analytics/index.js"},"./performance":{"types":"./dist/performance/index.d.ts","import":"./dist/performance/index.mjs","require":"./dist/performance/index.js"}},"gitHead":"84153813d2b6cc183f00f23d04cf0e887c512fbe","scripts":{"dev":"tsup src/index.ts src/device/index.ts src/performance/index.ts src/data/index.ts src/forms/index.ts src/analytics/index.ts --format cjs,esm --dts --watch","lint":"biome check .","test":"vitest run","build":"tsup src/index.ts src/device/index.ts src/performance/index.ts src/data/index.ts src/forms/index.ts src/analytics/index.ts --format cjs,esm --dts --clean","clean":"rm -rf dist node_modules/.cache","lint:fix":"biome check --write .","test:watch":"vitest"},"_npmUser":{"name":"antoineschaller","email":"antoine.schaller@akson.ch"},"repository":{"url":"git+https://github.com/antoineschaller/myarmy.git","type":"git","directory":"packages/@akson/cortex-landing-hooks"},"_npmVersion":"11.5.1","description":"React hooks for landing pages - device detection, API calls, form submission, analytics, and performance","directories":{},"_nodeVersion":"24.7.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","react":"^19.1.0","vitest":"^1.2.0","react-dom":"^19.1.0","typescript":"^5.3.3","@types/node":"^20.11.0","@types/react":"^19.0.0","@biomejs/biome":"^1.8.3","@types/react-dom":"^19.0.0"},"peerDependencies":{"react":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cortex-landing-hooks_0.3.0_1757682734678_0.6743844838750395","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Deprecated: inlined into consumer projects. No longer maintained."},"0.4.0":{"name":"@akson/cortex-landing-hooks","version":"0.4.0","keywords":["react","hooks","landing-page","mobile","performance","data","cortex","akson"],"author":{"name":"AKSON"},"license":"MIT","_id":"@akson/cortex-landing-hooks@0.4.0","maintainers":[{"name":"antoineschaller","email":"antoine.schaller@akson.ch"}],"homepage":"https://github.com/akson-ai/cortex-packages#readme","bugs":{"url":"https://github.com/akson-ai/cortex-packages/issues"},"dist":{"shasum":"f07311b9290c6081e1d6f5eb57c99cd9cf98e6eb","tarball":"https://registry.npmjs.org/@akson/cortex-landing-hooks/-/cortex-landing-hooks-0.4.0.tgz","fileCount":18,"integrity":"sha512-dtH+XUcibOTql9Rs7NTThzk5jFf9vp28zvdWXYKuwVXFA8wTxrCe4vQKEoHWvc53xYsUMkFpQMHqSJ5p+gbyuA==","signatures":[{"sig":"MEYCIQDE9VOaqIQY0398KXI8SXKbE7CdmLUEZvG1BMI4v2n7eAIhAJiXwrSh540cR85hBDZhjkZSIluFEPxPiLJP2TaKRR+M","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61643},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./data":{"types":"./dist/data.d.ts","import":"./dist/data.mjs","require":"./dist/data.js"},"./device":{"types":"./dist/device.d.ts","import":"./dist/device.mjs","require":"./dist/device.js"},"./performance":{"types":"./dist/performance.d.ts","import":"./dist/performance.mjs","require":"./dist/performance.js"}},"gitHead":"7a30fe44efdba549a19905e795dcfc934092d22a","scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest","build":"tsup","lint:fix":"biome check --write .","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"antoineschaller","email":"antoine.schaller@akson.ch"},"repository":{"url":"git+https://github.com/akson-ai/cortex-packages.git","type":"git","directory":"packages/landing-hooks"},"_npmVersion":"11.5.1","description":"React hooks for @akson/cortex landing pages","directories":{},"_nodeVersion":"24.7.0","dependencies":{},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","react":"^19.1.0","vitest":"^3.2.4","typescript":"^5.9.2","@types/node":"^22.18.1","@types/react":"^19.1.9","@biomejs/biome":"^2.2.2"},"peerDependencies":{"react":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cortex-landing-hooks_0.4.0_1758200599440_0.7638035585532488","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Deprecated: inlined into consumer projects. No longer maintained."},"0.4.1":{"name":"@akson/cortex-landing-hooks","version":"0.4.1","keywords":["akson","landing","react-hooks","device-detection","api-calls","form-submission","analytics","performance","image-preloader"],"author":{"name":"Akson","email":"contact@akson.ch"},"license":"MIT","_id":"@akson/cortex-landing-hooks@0.4.1","maintainers":[{"name":"antoineschaller","email":"antoine.schaller@akson.ch"}],"homepage":"https://github.com/antoineschaller/cortex-packages/tree/main/packages/@akson/cortex-landing-hooks","bugs":{"url":"https://github.com/antoineschaller/cortex-packages/issues"},"dist":{"shasum":"cb1138cafae58bb369bf4859eef498ea0d9eb539","tarball":"https://registry.npmjs.org/@akson/cortex-landing-hooks/-/cortex-landing-hooks-0.4.1.tgz","fileCount":33,"integrity":"sha512-7/wFHyEACSnwnUH0OpKm22j7wn1tx5i0TQ7eHJs4DqDLQ9IsK5dvIuVtZK2tRcxkX9Sswz3EQkEf+w6iyLpHRw==","signatures":[{"sig":"MEUCIC82pd784SmX4nW79PBcokqXfA9hzSzJbqXGNyIk5WgrAiEA2H3av4LUIB0hdChnRmnjHBQ93RNPEfkfGLywDoErGuU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":234930},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./data":{"types":"./dist/data/index.d.ts","import":"./dist/data/index.mjs","require":"./dist/data/index.js"},"./forms":{"types":"./dist/forms/index.d.ts","import":"./dist/forms/index.mjs","require":"./dist/forms/index.js"},"./device":{"types":"./dist/device/index.d.ts","import":"./dist/device/index.mjs","require":"./dist/device/index.js"},"./analytics":{"types":"./dist/analytics/index.d.ts","import":"./dist/analytics/index.mjs","require":"./dist/analytics/index.js"},"./performance":{"types":"./dist/performance/index.d.ts","import":"./dist/performance/index.mjs","require":"./dist/performance/index.js"}},"gitHead":"b3a6a0832bb2fd230473076bde1bfc7810e9ac31","scripts":{"dev":"tsup src/index.ts src/device/index.ts src/performance/index.ts src/data/index.ts src/forms/index.ts src/analytics/index.ts --format cjs,esm --dts --watch","lint":"biome check .","test":"vitest run","build":"tsup src/index.ts src/device/index.ts src/performance/index.ts src/data/index.ts src/forms/index.ts src/analytics/index.ts --format cjs,esm --dts --clean","clean":"rm -rf dist node_modules/.cache","lint:fix":"biome check --write .","test:watch":"vitest"},"_npmUser":{"name":"antoineschaller","email":"antoine.schaller@akson.ch"},"repository":{"url":"git+https://github.com/antoineschaller/cortex-packages.git","type":"git","directory":"packages/@akson/cortex-landing-hooks"},"_npmVersion":"11.5.1","description":"React hooks for landing pages - device detection, API calls, form submission, analytics, and performance","directories":{},"_nodeVersion":"24.7.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","react":"^19.1.0","vitest":"^1.2.0","react-dom":"^19.1.0","typescript":"^5.3.3","@types/node":"^20.11.0","@types/react":"^19.0.0","@biomejs/biome":"^1.8.3","@types/react-dom":"^19.0.0"},"peerDependencies":{"react":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cortex-landing-hooks_0.4.1_1758222752090_0.02379189511948554","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Deprecated: inlined into consumer projects. No longer maintained."}},"time":{"created":"2025-09-12T13:12:14.621Z","modified":"2026-03-19T11:54:45.781Z","0.3.0":"2025-09-12T13:12:14.850Z","0.4.0":"2025-09-18T13:03:19.624Z","0.4.1":"2025-09-18T19:12:32.331Z"},"bugs":{"url":"https://github.com/antoineschaller/cortex-packages/issues"},"author":{"name":"Akson","email":"contact@akson.ch"},"license":"MIT","homepage":"https://github.com/antoineschaller/cortex-packages/tree/main/packages/@akson/cortex-landing-hooks","keywords":["akson","landing","react-hooks","device-detection","api-calls","form-submission","analytics","performance","image-preloader"],"repository":{"url":"git+https://github.com/antoineschaller/cortex-packages.git","type":"git","directory":"packages/@akson/cortex-landing-hooks"},"description":"React hooks for landing pages - device detection, API calls, form submission, analytics, and performance","maintainers":[{"name":"antoineschaller","email":"antoine.schaller@akson.ch"}],"readme":"# @akson/cortex-landing-hooks\n\nReact hooks for landing pages - device detection, API calls, form submission, analytics, and performance optimization.\n\n## Installation\n\n```bash\nnpm install @akson/cortex-landing-hooks\n```\n\n## Features\n\n- **Device Detection** - Responsive breakpoints and screen size detection with SSR support\n- **API Calls** - Robust HTTP requests with retries, error handling, and authentication\n- **Form Submission** - Validation, debouncing, auto-save, and submission state management\n- **Analytics** - Multi-platform tracking (GTM, PostHog, Facebook Pixel) with type safety\n- **Performance** - Image preloading, lazy loading, and optimization utilities\n\n## Quick Start\n\n```tsx\nimport { \n  useMobileDetection, \n  useApiCall, \n  useFormSubmission,\n  useAnalytics,\n  useImagePreloader \n} from '@akson/cortex-landing-hooks';\n\nfunction MyLandingPage() {\n  // Device detection\n  const { isMobile, deviceType } = useMobileDetection();\n  \n  // API calls\n  const api = useApiCall({ \n    url: '/api/contact',\n    method: 'POST' \n  });\n  \n  // Form submission\n  const form = useFormSubmission({\n    endpoint: '/api/contact',\n    onSuccess: (data) => console.log('Success!', data)\n  });\n  \n  // Analytics\n  const analytics = useAnalytics({\n    gtmId: 'GTM-XXXXXXX',\n    posthogKey: 'phc_xxxxx'\n  });\n  \n  // Image preloading\n  const { progress } = useImagePreloader({\n    images: ['/hero.jpg', '/product1.jpg', '/product2.jpg']\n  });\n  \n  return (\n    <div>\n      {isMobile ? 'Mobile View' : 'Desktop View'}\n      <p>Preload progress: {progress}%</p>\n    </div>\n  );\n}\n```\n\n## Device Detection\n\n### useMobileDetection\n\nResponsive device detection with customizable breakpoints:\n\n```tsx\nimport { useMobileDetection } from '@akson/cortex-landing-hooks/device';\n\nfunction ResponsiveComponent() {\n  const { isMobile, isTablet, isDesktop, deviceType, screenWidth } = useMobileDetection({\n    mobileBreakpoint: 768,\n    tabletBreakpoint: 1024,\n    debounceMs: 150\n  });\n\n  return (\n    <div>\n      <p>Device: {deviceType}</p>\n      <p>Screen width: {screenWidth}px</p>\n      {isMobile && <MobileMenu />}\n      {isDesktop && <DesktopMenu />}\n    </div>\n  );\n}\n```\n\n### useWindowDimensions\n\nSafe window dimensions with SSR support:\n\n```tsx\nimport { useWindowDimensions } from '@akson/cortex-landing-hooks/device';\n\nfunction WindowInfo() {\n  const { width, height } = useWindowDimensions();\n  return <p>{width} × {height}</p>;\n}\n```\n\n## API Calls\n\n### useApiCall\n\nRobust API calls with retry logic:\n\n```tsx\nimport { useApiCall } from '@akson/cortex-landing-hooks/data';\n\nfunction UserProfile({ userId }) {\n  const { data, loading, error, execute } = useApiCall({\n    url: \\`/api/users/\\${userId}\\`,\n    retries: 3,\n    retryDelay: 1000,\n    onSuccess: (user) => console.log('User loaded:', user),\n    onError: (err) => console.error('Failed:', err)\n  });\n\n  useEffect(() => {\n    execute();\n  }, [userId]);\n\n  if (loading) return <div>Loading...</div>;\n  if (error) return <div>Error: {error.message}</div>;\n  return <div>Hello, {data?.name}!</div>;\n}\n```\n\n### useAuthenticatedApiCall\n\nAPI calls with authentication:\n\n```tsx\nimport { useAuthenticatedApiCall } from '@akson/cortex-landing-hooks/data';\n\nfunction ProtectedData() {\n  const api = useAuthenticatedApiCall({\n    url: '/api/protected',\n    getToken: () => localStorage.getItem('jwt_token')\n  });\n\n  return (\n    <button onClick={() => api.execute()}>\n      {api.loading ? 'Loading...' : 'Fetch Data'}\n    </button>\n  );\n}\n```\n\n## Form Submission\n\n### useFormSubmission\n\nAdvanced form handling with validation and auto-save:\n\n```tsx\nimport { useFormSubmission, createFormValidator, ValidationPatterns } from '@akson/cortex-landing-hooks/forms';\n\nconst validator = createFormValidator({\n  email: {\n    required: true,\n    pattern: ValidationPatterns.email\n  },\n  name: {\n    required: true,\n    minLength: 2\n  }\n});\n\nfunction ContactForm() {\n  const form = useFormSubmission({\n    endpoint: '/api/contact',\n    validateBeforeSubmit: validator,\n    autosave: true,\n    onSuccess: () => alert('Success!'),\n    onError: (error) => alert('Error: ' + error.message)\n  });\n\n  const handleSubmit = (e) => {\n    e.preventDefault();\n    const formData = new FormData(e.target);\n    form.submit(Object.fromEntries(formData));\n  };\n\n  return (\n    <form onSubmit={handleSubmit}>\n      <input name=\"email\" type=\"email\" required />\n      <input name=\"name\" type=\"text\" required />\n      \n      {form.validationErrors.map(error => (\n        <p key={error} style={{ color: 'red' }}>{error}</p>\n      ))}\n      \n      <button type=\"submit\" disabled={form.isSubmitting}>\n        {form.isSubmitting ? 'Submitting...' : 'Submit'}\n      </button>\n      \n      {form.success && <p style={{ color: 'green' }}>Form submitted successfully!</p>}\n      {form.isDirty && <p>Unsaved changes</p>}\n    </form>\n  );\n}\n```\n\n## Analytics\n\n### useAnalytics\n\nMulti-platform analytics tracking:\n\n```tsx\nimport { useAnalytics } from '@akson/cortex-landing-hooks/analytics';\n\nfunction AnalyticsExample() {\n  const analytics = useAnalytics({\n    gtmId: 'GTM-XXXXXXX',\n    posthogKey: 'phc_xxxxx',\n    debug: true\n  });\n\n  const handleButtonClick = () => {\n    analytics.track('button_click', {\n      button_name: 'hero_cta',\n      page: 'landing'\n    });\n  };\n\n  const handleFormSubmit = (userData) => {\n    analytics.identify(userData);\n    analytics.trackConversion('form_submission', 100);\n  };\n\n  useEffect(() => {\n    analytics.trackPageView();\n  }, []);\n\n  return (\n    <button onClick={handleButtonClick}>\n      Track This Click\n    </button>\n  );\n}\n```\n\n### useEcommerceAnalytics\n\nE-commerce specific tracking:\n\n```tsx\nimport { useEcommerceAnalytics } from '@akson/cortex-landing-hooks/analytics';\n\nfunction ProductPage({ product }) {\n  const analytics = useEcommerceAnalytics({ gtmId: 'GTM-XXXXXXX' });\n\n  useEffect(() => {\n    analytics.trackViewItem(product);\n  }, [product]);\n\n  const handleAddToCart = () => {\n    analytics.trackAddToCart(product);\n  };\n\n  const handlePurchase = (transactionId, items, total) => {\n    analytics.trackPurchase(transactionId, items, total);\n  };\n\n  return (\n    <div>\n      <h1>{product.name}</h1>\n      <button onClick={handleAddToCart}>Add to Cart</button>\n    </div>\n  );\n}\n```\n\n## Performance\n\n### useImagePreloader\n\nPreload images with progress tracking:\n\n```tsx\nimport { useImagePreloader } from '@akson/cortex-landing-hooks/performance';\n\nfunction ImageGallery() {\n  const { progress, loadedImages, isPreloading } = useImagePreloader({\n    images: [\n      '/gallery/image1.jpg',\n      '/gallery/image2.jpg',\n      '/gallery/image3.jpg'\n    ],\n    concurrency: 2,\n    onComplete: () => console.log('All images preloaded!'),\n    onError: (src, error) => console.warn('Failed to load:', src)\n  });\n\n  return (\n    <div>\n      {isPreloading && <p>Loading images... {progress}%</p>}\n      <div className=\"gallery\">\n        {images.map(src => (\n          <img \n            key={src} \n            src={src} \n            style={{ \n              opacity: loadedImages.has(src) ? 1 : 0.5 \n            }} \n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n```\n\n### useLazyImage\n\nLazy load images with intersection observer:\n\n```tsx\nimport { useLazyImage } from '@akson/cortex-landing-hooks/performance';\n\nfunction LazyImage({ src, alt }) {\n  const { \n    src: currentSrc, \n    isLoading, \n    hasLoaded, \n    ref \n  } = useLazyImage(src, {\n    placeholder: '/placeholder.jpg',\n    rootMargin: '50px'\n  });\n\n  return (\n    <img \n      ref={ref}\n      src={currentSrc}\n      alt={alt}\n      style={{\n        opacity: hasLoaded ? 1 : 0.5,\n        transition: 'opacity 0.3s ease'\n      }}\n    />\n  );\n}\n```\n\n## TypeScript\n\nAll hooks are fully typed with TypeScript. Import types as needed:\n\n```tsx\nimport type { \n  MobileDetection,\n  ApiCallResult,\n  FormSubmissionResult,\n  AnalyticsConfig \n} from '@akson/cortex-landing-hooks';\n```\n\n## License\n\nMIT","readmeFilename":"README.md"}