{"_id":"@api-zero/react","_rev":"6-78cafb12f161efa6ab854574b4b553fb","name":"@api-zero/react","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"@api-zero/react","version":"0.1.0","keywords":["api-zero","react","http","client","provider","hook"],"license":"MIT","_id":"@api-zero/react@0.1.0","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"ea9773f5f2697b41f79a885c3b2c871880114fdf","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.0.tgz","fileCount":9,"integrity":"sha512-zzIGu28XOlmUPSvdtp1bURzmA+0IoveXPz6csNJkmZ8lU3XQnkqCvaxJP51qhK5Yki/pYxrECnSJO1jf1Jpw5g==","signatures":[{"sig":"MEYCIQCmpeQcY5BXkceyOJTZ7ZHXNDgPhP7DBRkr2CeN9raQwwIhAPjr0yfFXLT7zxLcsQZNa83lv2XqgU/h7hTKM5gSn5WE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18398},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-react-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/ca52e3bbe26a584d0aa3b89d972c9fd3/api-zero-react-0.1.0.tgz","_integrity":"sha512-zzIGu28XOlmUPSvdtp1bURzmA+0IoveXPz6csNJkmZ8lU3XQnkqCvaxJP51qhK5Yki/pYxrECnSJO1jf1Jpw5g==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/react"},"_npmVersion":"11.17.0","description":"React bindings for api-zero — ApiProvider and useApi.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^18.3.1","vitest":"^1.0.0","happy-dom":"^15.0.0","react-dom":"^18.3.1","typescript":"^5.9.3","@types/react":"^18.0.0","@api-zero/core":"0.1.0","@types/react-dom":"^18.0.0","@testing-library/react":"^16.0.0"},"peerDependencies":{"react":">=18","@api-zero/core":">=0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.1.0_1787621524345_0.5124323554253056","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@api-zero/react","version":"0.1.1","keywords":["api-zero","react","http","client","provider","hook"],"license":"MIT","_id":"@api-zero/react@0.1.1","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"20b6b6ceb3ab862a39c185e8316af01d9852cab4","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.1.tgz","fileCount":9,"integrity":"sha512-1GhAqa0D0oUekLUhi9t3mw7iZUBDCxOOFMbnGd4usMxUUuCl+sTbfUWPECaBhMOasfwD358gdsYI2Jfwf4gK3Q==","signatures":[{"sig":"MEYCIQDnhavrdNeVkBV011LHohh5olNBn5GyFyO/lliWQaHz6AIhAKNJQiOMwArx5L7Z2Dn1uoY5keW9eMGoxzJ4drW4F2zz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18398},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-react-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/3af8c896074da5e05e0cad0cb73ce90a/api-zero-react-0.1.1.tgz","_integrity":"sha512-1GhAqa0D0oUekLUhi9t3mw7iZUBDCxOOFMbnGd4usMxUUuCl+sTbfUWPECaBhMOasfwD358gdsYI2Jfwf4gK3Q==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/react"},"_npmVersion":"11.17.0","description":"React bindings for api-zero — ApiProvider and useApi.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^19.2.0","vitest":"^1.0.0","happy-dom":"^15.0.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/react":"^19.2.5","@api-zero/core":"0.1.1","@types/react-dom":"^19.2.3","@testing-library/react":"^16.0.0"},"peerDependencies":{"react":">=18","@api-zero/core":">=0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.1.1_1787771963804_0.04906068421970233","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@api-zero/react","version":"0.1.2","keywords":["api-zero","react","http","client","provider","hook"],"license":"MIT","_id":"@api-zero/react@0.1.2","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"61c0b07be3c52d09a094ea69db9e773f6ffc67b0","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.2.tgz","fileCount":9,"integrity":"sha512-b0DMNGlHIWRbMMW1wGedF1j4+8dFCMiJ1Hoks9NjuKDs0L0B0HgS9QQnmi4nq4BBLgdei+LWXk6XaPBbdtE0Dg==","signatures":[{"sig":"MEQCIH9ySF6d/eUxQAGLYt6/Js4IA3N58M7GoBUxErTWrFoeAiAbOhs92YlZNPmXinIbCVqE5L0aQqKkpDHNTY5f+eiilg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18398},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-react-0.1.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/900f779f6586d0a2155e804a32f55a6f/api-zero-react-0.1.2.tgz","_integrity":"sha512-b0DMNGlHIWRbMMW1wGedF1j4+8dFCMiJ1Hoks9NjuKDs0L0B0HgS9QQnmi4nq4BBLgdei+LWXk6XaPBbdtE0Dg==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/react"},"_npmVersion":"11.17.0","description":"React bindings for api-zero — ApiProvider and useApi.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^19.2.0","vitest":"^1.0.0","happy-dom":"^15.0.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/react":"^19.2.5","@api-zero/core":"0.1.2","@types/react-dom":"^19.2.3","@testing-library/react":"^16.0.0"},"peerDependencies":{"react":">=18","@api-zero/core":">=0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.1.2_1787772563806_0.03768519519633218","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@api-zero/react","version":"0.1.3","keywords":["api-zero","react","http","client","provider","hook"],"license":"MIT","_id":"@api-zero/react@0.1.3","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"38189a9aa46f12f07b6fcaa338348929e9506d47","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.3.tgz","fileCount":9,"integrity":"sha512-/Al3sSUH1BBqoSBHisnvq0j1i7kLm/NpjWuRLCv4ILKr0br/q4aADH258CNmDe3Zvo1TIlSF7nrNPcg1Hhkfzg==","signatures":[{"sig":"MEQCIAij2X5xFIxHv5/Y2+Pe6un0z2KIFkqgsSUmCzPVrKQ1AiAcFx5To4O0u3W2QTcLVilQ/RTLC4lggUC5NiIqKnmoJA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18398},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-react-0.1.3.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/5692e0d232618675a115db45433de9d5/api-zero-react-0.1.3.tgz","_integrity":"sha512-/Al3sSUH1BBqoSBHisnvq0j1i7kLm/NpjWuRLCv4ILKr0br/q4aADH258CNmDe3Zvo1TIlSF7nrNPcg1Hhkfzg==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/react"},"_npmVersion":"11.17.0","description":"React bindings for api-zero — ApiProvider and useApi.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^19.2.0","vitest":"^1.0.0","happy-dom":"^15.0.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/react":"^19.2.5","@api-zero/core":"0.1.3","@types/react-dom":"^19.2.3","@testing-library/react":"^16.0.0"},"peerDependencies":{"react":">=18","@api-zero/core":">=0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.1.3_1787773901124_0.8501442299954602","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@api-zero/react","version":"0.1.4","keywords":["api-zero","react","http","client","provider","hook"],"license":"MIT","_id":"@api-zero/react@0.1.4","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"dist":{"shasum":"570f1fee66bf2d22e21ce2ffb8d1f3848d33d467","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.4.tgz","fileCount":9,"integrity":"sha512-pdhbtpAP9WGRIYIGHdcznbxbQgq+QzVt7FTPsO230TdlZef2SLWtlM/NoLu8C4E0Af+mK0IJ4n6vzbr1rWIr1Q==","signatures":[{"sig":"MEUCIQCrWTfFSuG1/5QUG8gLvVafTyikt60CF5Tf6EOe89lXHgIgdCK0r+ZmQkK24KjIDcplKbNKsOYkCA+Kn/y7OIqCjDE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18398},"main":"./dist/index.cjs","type":"module","_from":"file:api-zero-react-0.1.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"biome check .","test":"vitest run","build":"tsup","format":"biome format --write ."},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"_resolved":"/tmp/465089a95f2a7f08c33e9867c25466d5/api-zero-react-0.1.4.tgz","_integrity":"sha512-pdhbtpAP9WGRIYIGHdcznbxbQgq+QzVt7FTPsO230TdlZef2SLWtlM/NoLu8C4E0Af+mK0IJ4n6vzbr1rWIr1Q==","repository":{"url":"git+https://github.com/api-zero/api-zero.git","type":"git","directory":"packages/react"},"_npmVersion":"11.17.0","description":"React bindings for api-zero — ApiProvider and useApi.","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^19.2.0","vitest":"^1.0.0","happy-dom":"^15.0.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/react":"^19.2.5","@api-zero/core":"0.1.4","@types/react-dom":"^19.2.3","@testing-library/react":"^16.0.0"},"peerDependencies":{"react":">=18","@api-zero/core":">=0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.1.4_1787792132018_0.03985666709472091","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@api-zero/react","version":"0.1.5","description":"React bindings for api-zero — ApiProvider and useApi.","type":"module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/api-zero/api-zero.git","directory":"packages/react"},"homepage":"https://api-zero.vercel.app","bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"keywords":["api-zero","react","http","client","provider","hook"],"sideEffects":false,"engines":{"node":">=22"},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"peerDependencies":{"@api-zero/core":">=0.0.1","react":">=18"},"devDependencies":{"@testing-library/react":"^16.0.0","@types/react":"^19.2.5","@types/react-dom":"^19.2.3","happy-dom":"^15.0.0","react":"^19.2.0","react-dom":"^19.2.0","tsup":"^8.0.0","typescript":"^5.9.3","vitest":"^1.0.0","@api-zero/core":"0.1.5"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","lint":"biome check .","format":"biome format --write ."},"_id":"@api-zero/react@0.1.5","_integrity":"sha512-Mv9hCEKXwI+bPMTWbQmhwhCh/F1RfDDyPPxm6XV3C/AtEk6NbGb/F685aYzmswvLylqthsLX3PorXySD3iGONw==","_resolved":"/tmp/57ca8ee2cc610a20a8949474ed56827a/api-zero-react-0.1.5.tgz","_from":"file:api-zero-react-0.1.5.tgz","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-Mv9hCEKXwI+bPMTWbQmhwhCh/F1RfDDyPPxm6XV3C/AtEk6NbGb/F685aYzmswvLylqthsLX3PorXySD3iGONw==","shasum":"72974086457faa434c4155d5bc0c3469d30ed710","tarball":"https://registry.npmjs.org/@api-zero/react/-/react-0.1.5.tgz","fileCount":9,"unpackedSize":20118,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@api-zero%2freact@0.1.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGh1VyIYamvwYXMqHzrTSo7WFng+v/GLEReMexsn2x49AiEAx1/ReuZrmvEkeV5oYKfZLvG0uQZrsOdsRDHVKrDRUs0="}]},"_npmUser":{"name":"gorkadev","email":"dev@gorkadev.com"},"directories":{},"maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react_0.1.5_1787793180721_0.730574840698492"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-25T01:32:04.204Z","modified":"2026-08-27T01:13:01.305Z","0.1.0":"2026-08-25T01:32:04.516Z","0.1.1":"2026-08-26T19:19:23.981Z","0.1.2":"2026-08-26T19:29:23.946Z","0.1.3":"2026-08-26T19:51:41.260Z","0.1.4":"2026-08-27T00:55:32.154Z","0.1.5":"2026-08-27T01:13:00.886Z"},"bugs":{"url":"https://github.com/api-zero/api-zero/issues"},"license":"MIT","homepage":"https://api-zero.vercel.app","keywords":["api-zero","react","http","client","provider","hook"],"repository":{"type":"git","url":"git+https://github.com/api-zero/api-zero.git","directory":"packages/react"},"description":"React bindings for api-zero — ApiProvider and useApi.","maintainers":[{"name":"gorkadev","email":"dev@gorkadev.com"}],"readme":"# @api-zero/react\n\nReact bindings for `api-zero`: one configured client, available anywhere in the tree.\n\n## What this package is for\n\nEvery project ends up with the same hand-written `api.ts`: a client wrapper, a\nplace to stash the auth token, an interceptor or two, and re-declared `.get` /\n`.post` helpers. That file is what this package replaces.\n\n## What it deliberately is not\n\nIt is not a data-fetching library. There is no cache, no deduplication, no\ninvalidation, and no `useQuery` equivalent — those belong to\n[TanStack Query](https://tanstack.com/query) or [SWR](https://swr.vercel.app),\nwhich solve them far better than a transport layer should try to.\n\napi-zero is the transport and contract layer underneath them. Pairing the two is\nthe intended setup, not a workaround.\n\n## Installation\n\n```bash\nnpm install @api-zero/react @api-zero/core\n# or\npnpm add @api-zero/react @api-zero/core\n```\n\n## Usage\n\n### 1. Provide the client once\n\n`ApiProvider` accepts either an existing `client` or a `config`. Passing a\nclient you created yourself is the recommended form: it makes the instance's\nlifetime explicit and immune to re-render identity changes.\n\n```tsx\nimport { createClient } from \"@api-zero/core\";\nimport { ApiProvider } from \"@api-zero/react\";\nimport App from \"./App\";\n\nconst api = createClient({\n  baseURL: \"https://api.example.com\",\n  timeout: 10_000,\n});\n\nexport default function Root() {\n  return (\n    <ApiProvider client={api}>\n      <App />\n    </ApiProvider>\n  );\n}\n```\n\n### 2. Reach it anywhere with `useApi`\n\n```tsx\nimport { useApi } from \"@api-zero/react\";\n\nfunction LoginButton() {\n  const api = useApi();\n\n  async function signIn() {\n    const session = await api.post<{ token: string }>(\"/auth/login\", {\n      email: \"alice@example.com\",\n      password: \"…\",\n    });\n    api.setAuthToken(session.token);\n  }\n\n  return <button onClick={signIn}>Sign in</button>;\n}\n```\n\nEvery component now shares that client, its headers, its interceptors and its\nretry policy. No wrapper module, no token plumbing.\n\n### 3. Combine with TanStack Query\n\n`useApi()` returns the client; hand its request to `queryFn` and forward the\n`signal` TanStack provides so cancellation reaches the actual HTTP request.\n\n```tsx\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useApi } from \"@api-zero/react\";\n\nfunction useUser(id: number) {\n  const api = useApi();\n\n  return useQuery({\n    queryKey: [\"user\", id],\n    queryFn: ({ signal }) => api.get<User>(`/users/${id}`, { signal }),\n  });\n}\n```\n\nTanStack owns the cache and the server-state lifecycle. api-zero owns the\nrequest, the errors and the contract. Neither reimplements the other.\n\n## API\n\n| Export | Purpose |\n| --- | --- |\n| `ApiProvider` | Publishes an `ApiClient` to the tree, from a `client` or a `config`. |\n| `useApi()` | Returns the provided client. Throws outside a provider. |\n| `ApiContext` | The underlying context, for advanced composition. |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}