{"_id":"@amna1408/nextjs","_rev":"5-79921f5d616bba14a5d245a55ddf1a1c","name":"@amna1408/nextjs","description":"Usermaven JavaScript SDK for NextJS","dist-tags":{"latest":"1.5.0"},"versions":{"1.4.18":{"name":"@amna1408/nextjs","version":"1.4.18","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","_id":"@amna1408/nextjs@1.4.18","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"dist":{"shasum":"8b3e368ed1c6a41322f3947ef84d8e7860705fe6","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.4.18.tgz","fileCount":17,"integrity":"sha512-oD02Rs4ysxDdat6xQmduA2Ff8vWVA+HamBjOsFKeNCrhE1HV2C4pXbztrgsusGHRc2S7p7sl56iqBKDKYFjqpw==","signatures":[{"sig":"MEUCIChz6mS/DXHi/n3rK6/Wff8Lwdf4u74yjuHCxdwGP3LAAiEAkwjfiLT/O/Uzk4DtINL8Yexky2KdJlHVGYwpQG6hEbs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127048},"main":"lib/index.js","module":"lib/index.es.js","gitHead":"68aac5cab44b4cadfb68d0dd3d9ca1c008b26a6f","private":false,"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"rollup -c && tsc"},"typings":"lib/index.d.ts","_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"repository":{"url":"git+https://github.com/amna1408/usermaven-js.git","type":"git","directory":"packages/nextjs"},"_npmVersion":"10.7.0","description":"Usermaven JavaScript SDK for NextJS","directories":{"lib":"lib"},"_nodeVersion":"20.14.0","dependencies":{"cookie":"^0.5.0","@amna1408/sdk-js":"^1.2.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","@types/react":"^17.0.43","@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-typescript":"^8.3.1","@rollup/plugin-node-resolve":"^13.1.4","rollup-plugin-peer-deps-external":"^2.2.4"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_1.4.18_1719229642537_0.6259678477097415","host":"s3://npm-registry-packages"}},"1.4.19":{"name":"@amna1408/nextjs","version":"1.4.19","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","_id":"@amna1408/nextjs@1.4.19","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"dist":{"shasum":"87dc8d25fcb4c64c24d54a3b41ecdc4a240bf96f","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.4.19.tgz","fileCount":17,"integrity":"sha512-j0d+3iyDTNignWk0W7HcLHU5QsuyKSJwMoMuY0Cr2Wluw9G0YhsNvAQtNrmhizxp+JJR6xCXTyLx7htZsImOxw==","signatures":[{"sig":"MEUCIASDd6K6wvr7ezjzWYCwrDy77DWDrZmZ3+U8sAA1J1V5AiEA6/nfgYjL738/w+TWdgomdoQ1xdFpi8ErwL3Ql3xeqRc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127048},"main":"lib/index.js","module":"lib/index.es.js","gitHead":"1f1b7555b982cb25225a469728b5736113bea76b","private":false,"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"rollup -c && tsc"},"typings":"lib/index.d.ts","_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"repository":{"url":"git+https://github.com/amna1408/usermaven-js.git","type":"git","directory":"packages/nextjs"},"_npmVersion":"10.7.0","description":"Usermaven JavaScript SDK for NextJS","directories":{"lib":"lib"},"_nodeVersion":"20.14.0","dependencies":{"cookie":"^0.5.0","@amna1408/sdk-js":"^1.2.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","@types/react":"^17.0.43","@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-typescript":"^8.3.1","@rollup/plugin-node-resolve":"^13.1.4","rollup-plugin-peer-deps-external":"^2.2.4"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_1.4.19_1719230081050_0.506260386670704","host":"s3://npm-registry-packages"}},"1.4.20":{"name":"@amna1408/nextjs","version":"1.4.20","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","_id":"@amna1408/nextjs@1.4.20","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"dist":{"shasum":"39851f2d5ae1a2aab8d76580a2f587d6344a293f","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.4.20.tgz","fileCount":17,"integrity":"sha512-51wLmJTstggfyexbihNVwN4BYLAF+h7DjQF6MdlIqNGtm/w4k1FBZGu5IrgkxKS8l00bU6+L2BNG1RYkhBMwIQ==","signatures":[{"sig":"MEYCIQD7pNbmwUoMZI3PpM18KUCLK4iFpybCVz2tG0TetZygmQIhAMhA+w+K8v5WIg1Wjx68t1IpFJCYH9FojzscNINWanPi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127048},"main":"lib/index.js","module":"lib/index.es.js","gitHead":"d8d0fb8bf29b144eaf025d3a290c23ee5870aba2","private":false,"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"rollup -c && tsc"},"typings":"lib/index.d.ts","_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"repository":{"url":"git+https://github.com/amna1408/usermaven-js.git","type":"git","directory":"packages/nextjs"},"_npmVersion":"10.7.0","description":"Usermaven JavaScript SDK for NextJS","directories":{"lib":"lib"},"_nodeVersion":"20.15.0","dependencies":{"cookie":"^0.5.0","@amna1408/sdk-js":"^1.2.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","@types/react":"^17.0.43","@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-typescript":"^8.3.1","@rollup/plugin-node-resolve":"^13.1.4","rollup-plugin-peer-deps-external":"^2.2.4"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_1.4.20_1719573442204_0.1751721851491177","host":"s3://npm-registry-packages"}},"1.4.21":{"name":"@amna1408/nextjs","version":"1.4.21","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","_id":"@amna1408/nextjs@1.4.21","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"dist":{"shasum":"8cfdeee90a642b7b7d23492eabe8dae9581311d2","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.4.21.tgz","fileCount":17,"integrity":"sha512-pBy5ggbg/qbt+HUZS5qy/1bRCrxR8ryQFkaUaF0lMVTC4M+iGTU0a4FGDLyb9Q10dlOwjC1AFZzPxcRQEQXgXg==","signatures":[{"sig":"MEUCIQC7ONZXKFDAzTwZQv9o2lJhd/c7J1HUPfJRgFxt6dtXJQIgJ2zPkuSTmh9C8K1EcBfho2tuzLV/YdzIjwn0idHt+hA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127048},"main":"lib/index.js","module":"lib/index.es.js","gitHead":"f6a1f79c3c59b2c10aaba6606ac8c74bdb56ab6d","private":false,"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"rollup -c && tsc"},"typings":"lib/index.d.ts","_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"repository":{"url":"git+https://github.com/amna1408/usermaven-js.git","type":"git","directory":"packages/nextjs"},"_npmVersion":"10.7.0","description":"Usermaven JavaScript SDK for NextJS","directories":{"lib":"lib"},"_nodeVersion":"20.15.0","dependencies":{"cookie":"^0.5.0","@amna1408/sdk-js":"^1.2.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","@types/react":"^17.0.43","@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-typescript":"^8.3.1","@rollup/plugin-node-resolve":"^13.1.4","rollup-plugin-peer-deps-external":"^2.2.4"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_1.4.21_1719573659448_0.6424448844340105","host":"s3://npm-registry-packages"}},"1.4.22":{"name":"@amna1408/nextjs","version":"1.4.22","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","_id":"@amna1408/nextjs@1.4.22","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"dist":{"shasum":"97e84482026286d05275ede16d4120da88bb6679","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.4.22.tgz","fileCount":17,"integrity":"sha512-t8Xuwk/eH1GoTV/WcVlq+iF9SRqtcAbdzyap31zCbHNwoh16DzDgf5c2xuI8zXolIiO7mTj1faT3zI5fnHsMXw==","signatures":[{"sig":"MEQCIHnZaerdlo42t52Gr4ToZBs8PheN9iKy+kz78Chx3ZhxAiB3Y7pAbR8grjpocukXKDjpNKvf+4AoLepXKAoIxReZzw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127048},"main":"lib/index.js","module":"lib/index.es.js","gitHead":"e38a1d47b684e495c9c79e6e3df5ad1abfc45af0","private":false,"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"rollup -c && tsc"},"typings":"lib/index.d.ts","_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"repository":{"url":"git+https://github.com/amna1408/usermaven-js.git","type":"git","directory":"packages/nextjs"},"_npmVersion":"10.7.0","description":"Usermaven JavaScript SDK for NextJS","directories":{"lib":"lib"},"_nodeVersion":"20.15.0","dependencies":{"cookie":"^0.5.0","@amna1408/sdk-js":"^1.2.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","@types/react":"^17.0.43","@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-typescript":"^8.3.1","@rollup/plugin-node-resolve":"^13.1.4","rollup-plugin-peer-deps-external":"^2.2.4"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"_npmOperationalInternal":{"tmp":"tmp/nextjs_1.4.22_1719574328356_0.2141986137557612","host":"s3://npm-registry-packages"}},"1.5.0":{"name":"@amna1408/nextjs","version":"1.5.0","description":"Usermaven JavaScript SDK for NextJS","author":{"name":"Amna","email":"hello@usermaven.com"},"license":"MIT","main":"lib/index.js","typings":"lib/index.d.ts","module":"lib/index.es.js","private":false,"directories":{"lib":"lib"},"publishConfig":{"access":"public"},"dependencies":{"@amna1408/sdk-js":"^1.2.5","cookie":"^0.5.0"},"peerDependencies":{"next":"^10.0.8 || ^11.0 || ^12.0 || ^13.0","react":"15.x || 16.x || 17.x || 18.x"},"devDependencies":{"@rollup/plugin-commonjs":"^21.0.2","@rollup/plugin-node-resolve":"^13.1.4","@rollup/plugin-typescript":"^8.3.1","@types/react":"^17.0.43","next":"^12.1.5","react":"^17.0.2","rollup":"^2.70.1","rollup-plugin-peer-deps-external":"^2.2.4"},"scripts":{"build":"rollup -c && tsc","test":"echo \"Error: run tests from root\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/amna1408/usermaven-js.git","directory":"packages/nextjs"},"_id":"@amna1408/nextjs@1.5.0","gitHead":"7e5ca9145af2c5433a7b1a39ded52aa0dbbb0bed","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"homepage":"https://github.com/amna1408/usermaven-js#readme","_nodeVersion":"20.15.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-W2TFWtQlWf8Jkhs+sck48KTREYKhBzxVa9ee8brdskWwi8DTpe4XbLvJpjhBYXfgr2O1mFEsyiZjFXAw6/5rTw==","shasum":"191095e14c61846409debc4357a2cee29aa31c74","tarball":"https://registry.npmjs.org/@amna1408/nextjs/-/nextjs-1.5.0.tgz","fileCount":17,"unpackedSize":127047,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOrudWymDRc8C3q69Ae+EYknnoKgZnf+W1gSidS7amUwIhANZ04ezMH7orrfR0XwCvZT52B8HXAjRUNWkS//1Wo/ep"}]},"_npmUser":{"name":"amna0125","email":"amnaasaeed14@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nextjs_1.5.0_1719576261430_0.132394434978647"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-24T11:47:22.456Z","modified":"2024-06-28T12:04:21.871Z","1.4.18":"2024-06-24T11:47:22.692Z","1.4.19":"2024-06-24T11:54:41.223Z","1.4.20":"2024-06-28T11:17:22.386Z","1.4.21":"2024-06-28T11:20:59.633Z","1.4.22":"2024-06-28T11:32:08.521Z","1.5.0":"2024-06-28T12:04:21.691Z"},"maintainers":[{"name":"amna0125","email":"amnaasaeed14@gmail.com"}],"author":{"name":"Amna","email":"hello@usermaven.com"},"repository":{"type":"git","url":"git+https://github.com/amna1408/usermaven-js.git","directory":"packages/nextjs"},"license":"MIT","homepage":"https://github.com/amna1408/usermaven-js#readme","bugs":{"url":"https://github.com/amna1408/usermaven-js/issues"},"readme":"# Official Usermaven SDK for NextJS\n\n\n## General\n\nThis package is a wrapper around `@usermaven/sdk-js`, with added functionality related to NextJS.\n\n## Installation\n\nWith NextJS there're several ways on how to add Usermaven tracking\n\n## Client Side Tracking\n\nFirst, create or update your `_app.js` following this code\n```jsx\nimport { createClient, UsermavenProvider } from \"@usermaven/nextjs\";\n\n// initialize Usermaven client\nconst usermavenClient = createClient({\n  tracking_host: \"__USERMAVEN_HOST__\",\n  key: \"__API_KET__\",\n  // See Usermaven SDK parameters section for more options\n});\n\n// wrap our app with Usermaven provider\nfunction MyApp({Component, pageProps}) {\n  return <UsermavenProvider client={usermavenClient}>\n    <Component {...pageProps} />\n  </UsermavenProvider>\n}\n\nexport default MyApp\n```\nSee [parameters list](https://usermaven.com/docs/sending-data/js-sdk/parameters-reference) for `createClient()` call.\n\nAfter usermaven client and provider are configured you will be able to use `useUsermaven` hook in your components\n```jsx\nimport { useUsermaven } from \"@usermaven/nextjs\";\n\nconst Main = () => {\n  const {id, trackPageView, track} = useUsermaven(); // import methods from useUsermaven hook\n\n  useEffect(() => {\n    id({id: '__USER_ID__', email: '__USER_EMAIL__'}); // identify current user for all events\n    trackPageView() // send pageview event\n  }, [])\n\n  const onClick = (btnName) => {\n    track('btn_click', {btn: btnName}); // send btn_click event with button name payload on click\n  }\n\n  return (\n    <button onClick=\"() => onClick('test_btn')\">Test button</button>\n  )\n}\n```\nPlease note, that `useUsermaven` uses `useEffect()` with related side effects.\n\n\\\nTo enable automatic pageview tracking, add `usePageView()` hook to your `_app.js`. This hook will send pageview each time\nuser loads a new page. This hook relies on [NextJS Router](https://nextjs.org/docs/api-reference/next/router)\n```jsx\nimport { createClient, UsermavenProvider } from \"@usermaven/nextjs\";\n\n// initialize Usermaven client\nconst usermavenClient = createClient({\n  tracking_host: \"__USERMAVEN_HOST__\",\n  key: \"__API_KET__\",\n  // See Usermaven SDK parameters section for more options\n});\n\nfunction MyApp({Component, pageProps}) {\n  usePageView(usermavenClient); // this hook will send pageview track event on router change\n\n  // wrap our app with Usermaven provider\n  return <UsermavenProvider client={usermavenClient}>\n    <Component {...pageProps} />\n  </UsermavenProvider>\n}\n\nexport default MyApp\n```\nIf you need to pre-configure usermaven event - for example, identify a user, it's possible to do via `before` callback:\n```javascript\nusePageView(usermavenClient, {before: (usermaven) => usermaven.id({id: '__USER_ID__', email: '__USER_EMAIL__'})})\n```\n\n## Server Side Tracking\n\nUsermaven can track events on server-side:\n* **Pros:** this method is 100% reliable and ad-block resistant\n* **Cons:** static rendering will not be possible; `next export` will not work; fewer data points will be collected - attributes such as screen-size, device\n\n### Manual tracking\n\nFor manual tracking you need to initialize Usermaven client\n```javascript\nimport { createClient } from \"@usermaven/nextjs\";\n\n// initialize Usermaven client\nconst usermavenClient = createClient({\n  tracking_host: \"__USERMAVEN_HOST__\",\n  key: \"__API_KET__\",\n  // See Usermaven SDK parameters section for more options\n});\n```\nafter that, you will be able to user [Usermaven client](https://usermaven.com/docs/sending-data/js-sdk/methods-reference), for example, in `getServerSideProps`\n```\nexport async function getServerSideProps() {\n  usermaven.track(\"page_view\", {page: req.page})\n\n  return { props: {} }\n}\n```\n\n### Automated page view tracking\n\nUsermaven could track page views automatically via use of `_middleware.js` which has been introduced in NextJS 12\n\n```javascript\nexport function middleware(req, ev) {\n  const {page} = req\n  if ( !page?.name ) {\n    return;\n  }\n  usermaven.track(\"page_view\", {page: req.page})\n}\n```\n\n\n## Example app\n\nYou can find example app [here](https://github.com/usermaven/usermaven-next-example).","readmeFilename":"README.md"}