{"_id":"@bisham/react-jwt-auth","_rev":"7-2c35bd5ea389e798eb0923ad2206264d","name":"@bisham/react-jwt-auth","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"@bisham/react-jwt-auth","version":"0.1.0","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.1.0","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"dist":{"shasum":"4fcd422e59a290c9b41b66745771d3f1ff65c2be","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.1.0.tgz","fileCount":9,"integrity":"sha512-PWIbljFJbDYz7c+79jz4TAtaknxyZCb2zY/LtdquhGvwxFLMFbdXw7xrv15ZRMHEDyj0lFMefbu8hi+cuSJjOA==","signatures":[{"sig":"MEQCIE1SbWUbmh8N4yrzHreC+7jnDoSaW5h1nN5x60YR5EMHAiAaXkxQhF2XKj+NZ35a9Mhz5bPJSkyfLfIXvVJLOrU8qA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":22317},"main":"src/index.ts","gitHead":"de77aedffa575a7fcc26d7cb42e60b752c3a397a","_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.1"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.1.0_1734942412991_0.4033814528209394","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@bisham/react-jwt-auth","version":"0.2.0","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.2.0","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"dist":{"shasum":"bfbf225c276d612e70ec054a840bd15531177da7","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.2.0.tgz","fileCount":4,"integrity":"sha512-b7W3oI3+QQs9elTI0YkdXH6uIm+8/QDZAzdmObmZhHnQrL3sRh67/BFJbGlIwqr9DCL0seawGVAp41oiG8SduQ==","signatures":[{"sig":"MEUCIBbW9rLKpnCDGpp3WXlTzRGfAvsyxGW8ONteRZMoCjTuAiEAwrMV8DEOZxAJxQCdWYOBJyrB6/UHukQ+73TKSvIV1FY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23624},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"974f26952318e1a98e019502703193ffc52a8a74","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.2.0_1735675345691_0.7973085667533872","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@bisham/react-jwt-auth","version":"0.2.1","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.2.1","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"dist":{"shasum":"46162a1fbe1689bd913b7aa6d21b566f5f90c4bf","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.2.1.tgz","fileCount":5,"integrity":"sha512-wPtUsGk0XDHnabYo59kPl7a2ELHzw00VBIGFgPoArcX5LpHawdcYYUUtbw1aGrTlWAWiGKIzcHJsZVci9sbetQ==","signatures":[{"sig":"MEYCIQD2Sso0ILr13Zrk7Slus4ks4Nxi0/4Xseq+lmvqsSRt+gIhAOrI1UMEYKVbcrHoXuCvOlk1xFEABAnsPek5Jj8beEIj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":28640},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"d39ee3f33e683a8590e70b67babfbd7770bb1138","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.2.1_1735679929297_0.47822448660994143","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@bisham/react-jwt-auth","version":"0.2.2","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.2.2","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"dist":{"shasum":"b65f81b45889dd9684b5a4bd20711e32a0fe2154","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.2.2.tgz","fileCount":4,"integrity":"sha512-2Zancr0SH6+tfr0x8MRzVw2Ob5vjTbac+XbVuKisI4vXn2ZT1RUMJi7fjYN6EFQSkV4ba2UTDnJmoATwwuQM5A==","signatures":[{"sig":"MEUCIGkKBU5DqRRsOx2DsDWk4aBzlMjRsd880/iEXskE1MvbAiEA6hgCrQIK8a8mBiTr97g/CE7RsRE0y5Aww0SwOvrpTrU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9581},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"6f63236142bf6779a82ee0051d822e6777cf0e3e","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","dependencies":{"@rollup/plugin-terser":"^0.4.4"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.2.2_1735705946276_0.5121345763254208","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"@bisham/react-jwt-auth","version":"0.2.3","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.2.3","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"07f2a0b30c0ee0663c538387cc85b1e4bb3907b5","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.2.3.tgz","fileCount":4,"integrity":"sha512-J8Lhv6cbeavMd9J4rMVmvtrws/bGooYF/dt+VSGJyGvN8PyuUNpghAHXDhPyusRO4+eAnKjflJfsE/pzer8hcw==","signatures":[{"sig":"MEUCIQCJFApSzvXei86UboJ7Od6aRblZEOGCppgNG1cwsvYqfwIgBoJKZaShSmc3GQfm1xBhYz2AtZxgOKsDdMVnnwbaU6M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9709},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"59b8c2ddc95f5caca23d203d1a99ddfa9bfa4872","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/react-jwt-auth"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.2.3_1735706402247_0.9058895515548366","host":"s3://npm-registry-packages-npm-production"}},"0.2.4":{"name":"@bisham/react-jwt-auth","version":"0.2.4","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.2.4","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"861640df4d9646f3a4eec291684264b2b7bf681a","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.2.4.tgz","fileCount":4,"integrity":"sha512-QsQ8K4+S1TTTBu1xC+G8g8T76LnWhj1k3ThCKLHNVe5xRsN24VSmqdsAtxPlVKeijKI/i/MXKdm0GHDdYSyExg==","signatures":[{"sig":"MEQCIC9H2Nbx2nbIGZCff7r0gR3Pu8TAsLnRoeACh16fv1ISAiA77fYgkK4wOlZlJRrSCHO0zE/Z19mYVxHeKaFIeRVIlw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9674},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"31ab8d2f2422012370c8f5924b67946d99ac3c14","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/react-jwt-auth"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.2.4_1735707794065_0.42766163173969685","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@bisham/react-jwt-auth","version":"0.3.0","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/react-jwt-auth@0.3.0","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"76a7b16160e77f74fd90dc7d3bb7dd050a63303e","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.3.0.tgz","fileCount":4,"integrity":"sha512-jo/oZLsoH4SBqiPxF5jLEdMJZA+3LVKMiYaIKDHf2kF0689WV3S29BFh9YE6OQDj3GOm7X7/VjUw+jjjQRbF7Q==","signatures":[{"sig":"MEUCIAHnlMQe9eg6Swaxes8+GQ9C5/4qcynJRdz0nNrJphgIAiEArLqFwh3YZ+fy3S5Pvuv4ulp9QIqgMDgkqDnTxsvRYeg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10769},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3f48c51960da2d9b016c749eb3b2a5b587cc2843","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/react-jwt-auth"},"_npmVersion":"10.8.2","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","typescript":"^5.7.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup-plugin-dts":"^6.1.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.2","@rollup/plugin-node-resolve":"^16.0.0"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-jwt-auth_0.3.0_1735839621381_0.13079306884150066","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@bisham/react-jwt-auth","version":"0.3.1","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"dev":"rollup -c -w","build":"rm -rf ./dist && rollup -c"},"peerDependencies":{"axios":"^1.7.9","dayjs":"^1.11.13","react":"^19.0.0"},"keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"author":{"name":"Bisham Kunwor","email":"novelian.nova@gmail.com","url":"https://bishamkunwor.com.np"},"repository":{"type":"git","url":"git+https://github.com/BishamKunwor/BishamKunwor.git","directory":"packages/react-jwt-auth"},"license":"MIT","description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","devDependencies":{"@rollup/plugin-node-resolve":"^16.0.0","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.2","@types/node":"^22.10.2","@types/react":"^19.0.2","rollup":"^4.29.1","rollup-plugin-dts":"^6.1.1","tslib":"^2.8.1","typescript":"^5.7.2"},"_id":"@bisham/react-jwt-auth@0.3.1","gitHead":"9a7cb43fef84af13f426f3e4381a627c903210bb","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-xg5bLe2aYng1Y4WwblhTvykvI/lJYAt8AGnWVH8D6ZC3bLXLv/EWtQqo9jVxBB+KRAop1U01Y6yukSjH6cJsHA==","shasum":"0e2522a4896a1f05be96714498ee05f34d2906bc","tarball":"https://registry.npmjs.org/@bisham/react-jwt-auth/-/react-jwt-auth-0.3.1.tgz","fileCount":4,"unpackedSize":10937,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGc6sWC4imTF+Q/kKh0bRS+7XMfWVJxabFN4cM7DD7T1AiAGv5k1Wlef16HmX1UbYbsqQv2l78uGOeMXQnnmPnjprw=="}]},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"directories":{},"maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-jwt-auth_0.3.1_1736515215338_0.44072754636564504"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-23T08:26:52.920Z","modified":"2025-01-10T13:20:15.726Z","0.1.0":"2024-12-23T08:26:53.156Z","0.2.0":"2024-12-31T20:02:25.877Z","0.2.1":"2024-12-31T21:18:49.502Z","0.2.2":"2025-01-01T04:32:26.448Z","0.2.3":"2025-01-01T04:40:02.422Z","0.2.4":"2025-01-01T05:03:14.258Z","0.3.0":"2025-01-02T17:40:21.537Z","0.3.1":"2025-01-10T13:20:15.514Z"},"bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"author":{"name":"Bisham Kunwor","email":"novelian.nova@gmail.com","url":"https://bishamkunwor.com.np"},"license":"MIT","homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","keywords":["jwt","auth","react-auth","react-jwt-auth","jwt-auth"],"repository":{"type":"git","url":"git+https://github.com/BishamKunwor/BishamKunwor.git","directory":"packages/react-jwt-auth"},"description":"React Jwt Auth is an auth state management library that handles all the core functionality of jwt auth including de-duping, attaching auth token in each request","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"readme":"## Overview\n\n`@bisham/react-jwt-auth` simplifies JWT authentication flow in your React apps by managing access tokens, including automatic handling of token expiration, refreshing tokens, and deduplication of token fetch requests.\n\n## Features\n\n- **JWT Token Validation**: Ensures that the JWT token format is correct and checks the expiration (`exp`) field if it exist.\n- **Token Expiration Handling**: Automatically detects when the token has expired and triggers a refresh when `exp` is in jwt payload.\n- **Automatic Token Refresh**: Supports automatic fetching of new access tokens and handles deduplication of token requests.\n- **Secure Authorization Context**: Provides a context for managing the user's authentication state across your app.\n- **Seamless Integration with Axios**: Automatically attaches the `Authorization` header with the correct access token in your `axios` requests.\n- **Flexible Debugging**: Enables detailed debug logging to help you track the authentication flow.\n\n## Installation\n\nTo install the package, run the following command:\n\n```bash\nnpm install @bisham/react-jwt-auth\n```\n\nor\n\n```bash\nyarn add @bisham/react-jwt-auth\n```\n\n## Usage\n\n### Setting Up the `AuthProvider`\n\nWrap your application with the `AuthProvider` component to manage authentication state across your app.\n\n```jsx\nimport React from \"react\";\nimport { AuthProvider } from \"@bisham/react-jwt-auth\";\nimport axios from \"axios\";\n\nconst axiosPrivate = axios.create({\n  baseURL: \"https://api.example.com\",\n  // other axios configuration\n});\n\nconst getAccessToken = async () => {\n  // Implement your token fetching logic (e.g., from localStorage or a refresh API)\n};\n\nconst App = () => {\n  return (\n    <AuthProvider\n      axiosInstance={axiosPrivate}\n      defaultValue={{ accessToken: localStorage.getItem(\"accessToken\") }}\n      getAccessToken={getAccessToken}\n      debug\n      onSignOut={() => console.log(\"Signed out\")}\n      onSignIn={(accessToken)=>{\n        // something to do when user signs in into the app\n        // using signIn callback provided by `useAuth`\n      }}\n    >\n      {/* Your app components */}\n    </AuthProvider>\n  );\n};\n\nexport default App;\n```\n\n### Accessing Authentication State\n\nYou can access the authentication state anywhere in your app using the `useAuth` hook:\n\n```jsx\nimport { useAuth } from \"@bisham/react-jwt-auth\";\n\nconst MyComponent = () => {\n  const { isAuthenticated, signOut } = useAuth();\n\n  const fetchData = async () => {\n    try {\n      // Authentication is Handled by AuthProvider Wrapper\n      const response = await axiosPrivate.get(\"/protected-data\", {});\n      console.log(response.data);\n    } catch (error) {\n      console.error(\"Error fetching data:\", error);\n    }\n  };\n\n  return (\n    <div>\n      {isAuthenticated ? (\n        <div>\n          <button onClick={fetchData}>Fetch Protected Data</button>\n          <button onClick={signOut}>Sign Out</button>\n        </div>\n      ) : (\n        <p>You are not authenticated</p>\n      )}\n    </div>\n  );\n};\n```\n\n### Handling Token Expiration\n\nThis package checks that the JWT token includes the `exp` (expiration) field in the payload. If the token is expired, the package will automatically try to refresh the token by calling the `getNewTokens` function you provide. If `exp` field is missing then it will check if server is sending 401 error then retry to `getNewTokens` method.\n\n## API\n\n### `AuthProvider`\n\n- **Props**:\n  - `axiosInstance` (required): An instance of Axios that will be used for authenticated requests.\n  - `defaultValue` (optional): An object containing the initial `accessToken`.\n  - `getAccessToken` (required): A function that fetches the access token.\n  - `debug` (optional): Boolean flag to enable or disable debug logging (default: `false`).\n  - `onSignOut` (optional): A callback function that is triggered when the user signs out.\n\n### `useAuth`\n\n- **Returns**: An object containing the following methods and properties:\n  - `isAuthenticated`: Boolean indicating whether the user is authenticated.\n  - `signIn(accessToken)`: Function to sign the user in with the provided `accessToken`.\n  - `signOut()`: Function to sign the user out.\n  - `getAccessToken()`: Function to get the current access token (or fetch a new one if expired).\n  - `onSignIn`: Function callback that is triggered when user signs in via signin function provided by `useAuth`.\n\n## Important Notes\n\n- Make sure your token fetching logic in `getAccessToken` is set up properly to handle token expiration and refreshing.\n- If you encounter issues or need debugging, enable the `debug` flag when using `AuthProvider` to get detailed logs.\n\n## License\n\nThis package is licensed under the MIT License.\n\n---\n\nFor any questions or feature requests, feel free to open an issue on the [GitHub repository](https://github.com/BishamKunwor/BishamKunwor/tree/main/packages/react-jwt-auth).\n","readmeFilename":"readme.md"}