{"_id":"@api-hooks/pkggo","name":"@api-hooks/pkggo","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@api-hooks/pkggo","version":"1.0.0","description":"React hooks for the Go module proxy and pkg.go.dev, built on @tanstack/react-query","keywords":["react","hooks","pkggo","go","golang","module-proxy","registry","api","react-query","tanstack"],"license":"MIT","homepage":"https://github.com/ElJijuna/api-hooks#readme","repository":{"type":"git","url":"git+https://github.com/ElJijuna/api-hooks.git","directory":"packages/pkggo"},"bugs":{"url":"https://github.com/ElJijuna/api-hooks/issues"},"publishConfig":{"access":"public"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./types":{"types":"./dist/types.d.ts","import":"./dist/types.js"}},"sideEffects":false,"scripts":{"build":"vite build && tsc --emitDeclarationOnly --declarationMap","dev":"vite build --watch","test":"jest --passWithNoTests","test:coverage":"jest --coverage --passWithNoTests","typecheck":"tsc --noEmit","docs":"typedoc"},"peerDependencies":{"@tanstack/react-query":"^5.0.0","react":">=19.0.0"},"dependencies":{"pkggo-api-client":"^1.0.0"},"devDependencies":{"@tanstack/react-query":"^5.101.0","@testing-library/react":"^16.3.2","jest":"^30.4.2","jest-environment-jsdom":"^30.4.1","react":"^19.2.7","react-dom":"^19.2.7","typedoc":"^0.28.19","vite":"^8.0.16","vite-magic-tree-shaking":"^1.0.0"},"author":{"name":"pilmee","email":"pilmee@gmail.com","url":"https://github.com/ElJijuna"},"gitHead":"0d7aeeefefbf8036fb080241b07cdbcbd758f0ad","_id":"@api-hooks/pkggo@1.0.0","_nodeVersion":"22.23.1","_npmVersion":"11.18.0","dist":{"integrity":"sha512-dxFZaupI8L0tIe+hjDzI/3MSHvqYhlUlRP7WnEvJkv8B4ZDjolFUKyf/NA9vPrcbLV9NXYomOJowYsvgCATd2g==","shasum":"30afa5b6da35fd6f6a01b4950d703d47a209d023","tarball":"https://registry.npmjs.org/@api-hooks/pkggo/-/pkggo-1.0.0.tgz","fileCount":39,"unpackedSize":34702,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDy2h73utIWJxFguc8J5eoRN/5toS3bxG1t3l6GIe5lRQIgFKV/jHhQ6YurNicG1AxHHgJRZSf9gwIgGf4M0ZOSREE="}]},"_npmUser":{"name":"pilmee","email":"pilmee@gmail.com"},"directories":{},"maintainers":[{"name":"pilmee","email":"pilmee@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pkggo_1.0.0_1783080430826_0.13712793580605576"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T12:07:10.695Z","1.0.0":"2026-07-03T12:07:10.951Z","modified":"2026-07-03T12:07:11.152Z"},"maintainers":[{"name":"pilmee","email":"pilmee@gmail.com"}],"description":"React hooks for the Go module proxy and pkg.go.dev, built on @tanstack/react-query","homepage":"https://github.com/ElJijuna/api-hooks#readme","keywords":["react","hooks","pkggo","go","golang","module-proxy","registry","api","react-query","tanstack"],"repository":{"type":"git","url":"git+https://github.com/ElJijuna/api-hooks.git","directory":"packages/pkggo"},"author":{"name":"pilmee","email":"pilmee@gmail.com","url":"https://github.com/ElJijuna"},"bugs":{"url":"https://github.com/ElJijuna/api-hooks/issues"},"license":"MIT","readme":"# @api-hooks/pkggo\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/ElJijuna/api-hooks/main/public/assets/api-hooks.png\" alt=\"api-hooks logo\" width=\"240\" />\n</p>\n\nReact hooks for the [Go module proxy](https://go.dev/ref/mod#goproxy-protocol) and [pkg.go.dev](https://pkg.go.dev), built on [`pkggo-api-client`](https://www.npmjs.com/package/pkggo-api-client) and [`@tanstack/react-query`](https://tanstack.com/query).\n\n[![npm](https://img.shields.io/npm/v/@api-hooks/pkggo)](https://www.npmjs.com/package/@api-hooks/pkggo)\n[![npm downloads](https://img.shields.io/npm/dm/@api-hooks/pkggo)](https://www.npmjs.com/package/@api-hooks/pkggo)\n[![CI](https://github.com/ElJijuna/api-hooks/actions/workflows/ci.yml/badge.svg)](https://github.com/ElJijuna/api-hooks/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](../../LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)\n\n## Requirements\n\n| Peer dependency | Version |\n| --------------- | ------- |\n| `react` | `>=19.0.0` |\n| `@tanstack/react-query` | `^5.0.0` |\n\n## Installation\n\n```bash\nnpm install @api-hooks/pkggo @tanstack/react-query\n```\n\n## Setup\n\nWrap your application with a `QueryClientProvider` and a `PkgGoClientProvider` once at the root:\n\n```tsx\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { PkgGoClientProvider } from '@api-hooks/pkggo';\n\nconst queryClient = new QueryClient();\n\nexport default function App() {\n  return (\n    <QueryClientProvider client={queryClient}>\n      <PkgGoClientProvider>\n        <YourApp />\n      </PkgGoClientProvider>\n    </QueryClientProvider>\n  );\n}\n```\n\nBy default, requests go to `proxy.golang.org` (docs links point at `pkg.go.dev`). To point at a private module proxy (e.g. Athens, GOPROXY mirror), pass `proxyUrl`/`pkgGoDevUrl` through `PkgGoClientProvider`:\n\n```tsx\n<PkgGoClientProvider\n  options={{\n    proxyUrl: 'https://my-goproxy.example.com',\n    pkgGoDevUrl: 'https://my-docs.example.com',\n  }}\n>\n  <YourApp />\n</PkgGoClientProvider>\n```\n\n`PkgGoClientProvider` is optional — hooks fall back to a default `PkgGoClient` (pointed at `proxy.golang.org`) when no provider is present.\n\n## Hooks\n\nQuery hooks return a [`UseQueryResult`](https://tanstack.com/query/latest/docs/framework/react/reference/useQuery) — you get the full TanStack Query API: `data`, `isLoading`, `isFetching`, `isError`, `error`, `refetch`, and more.\n\n| Hook | Description | Returns |\n| ---- | ----------- | ------- |\n| [`usePkgGoModuleLatest(modulePath, options?)`](#usepkggomodulelatestmodulepath-options) | Latest module info | `GoModuleInfo` |\n| [`usePkgGoModuleVersions(modulePath, options?)`](#usepkggomoduleversionsmodulepath-options) | All known module versions | `string[]` |\n| [`usePkgGoVersionInfo(modulePath, version, options?)`](#usepkggoversioninfomodulepath-version-options) | Metadata for a specific version | `GoModuleInfo` |\n| [`usePkgGoVersionMod(modulePath, version, options?)`](#usepkggoversionmodmodulepath-version-options) | Raw `go.mod` file contents | `string` |\n| [`usePkgGoVersionZip(modulePath, version, options?)`](#usepkggoversionzipmodulepath-version-options) | Module zip archive bytes | `ArrayBuffer` |\n\n---\n\n## API Reference\n\n### `usePkgGoModuleLatest(modulePath, options?)`\n\nFetches the latest module info from the Go module proxy `@latest` endpoint.\n\n```tsx\nimport { usePkgGoModuleLatest } from '@api-hooks/pkggo';\n\nfunction LatestVersion() {\n  const { data } = usePkgGoModuleLatest('golang.org/x/mod');\n\n  return <p>Latest: {data?.Version}</p>;\n}\n```\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| `enabled` | `boolean` | `true` | Disable the query (also disabled when `modulePath` is empty) |\n| `queryOptions` | `QueryOverrides<TData>` | `undefined` | Override TanStack Query options (`staleTime`, `retry`, `gcTime`, `select`, etc.) |\n\n---\n\n### `usePkgGoModuleVersions(modulePath, options?)`\n\nLists module versions known by the configured Go module proxy.\n\n```tsx\nimport { usePkgGoModuleVersions } from '@api-hooks/pkggo';\n\nfunction VersionList() {\n  const { data } = usePkgGoModuleVersions('golang.org/x/mod');\n\n  return <ul>{data?.map(v => <li key={v}>{v}</li>)}</ul>;\n}\n```\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| `enabled` | `boolean` | `true` | Disable the query (also disabled when `modulePath` is empty) |\n| `queryOptions` | `QueryOverrides<TData>` | `undefined` | Override TanStack Query options (`staleTime`, `retry`, `gcTime`, `select`, etc.) |\n\n---\n\n### `usePkgGoVersionInfo(modulePath, version, options?)`\n\nFetches metadata for a specific module version.\n\n```tsx\nimport { usePkgGoVersionInfo } from '@api-hooks/pkggo';\n\nfunction VersionDetail() {\n  const { data } = usePkgGoVersionInfo('golang.org/x/mod', 'v0.37.0');\n\n  return <p>Published: {data?.Time}</p>;\n}\n```\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| `enabled` | `boolean` | `true` | Disable the query (also disabled when `modulePath` or `version` is empty) |\n| `queryOptions` | `QueryOverrides<TData>` | `undefined` | Override TanStack Query options (`staleTime`, `retry`, `gcTime`, `select`, etc.) |\n\n---\n\n### `usePkgGoVersionMod(modulePath, version, options?)`\n\nFetches the raw `go.mod` file contents for a module version.\n\n```tsx\nimport { usePkgGoVersionMod } from '@api-hooks/pkggo';\n\nfunction GoModViewer() {\n  const { data } = usePkgGoVersionMod('golang.org/x/mod', 'v0.37.0');\n\n  return <pre>{data}</pre>;\n}\n```\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| `enabled` | `boolean` | `true` | Disable the query (also disabled when `modulePath` or `version` is empty) |\n| `queryOptions` | `QueryOverrides<TData>` | `undefined` | Override TanStack Query options (`staleTime`, `retry`, `gcTime`, `select`, etc.) |\n\n---\n\n### `usePkgGoVersionZip(modulePath, version, options?)`\n\nDownloads the module zip archive for a version.\n\n```tsx\nimport { usePkgGoVersionZip } from '@api-hooks/pkggo';\n\nfunction DownloadZip() {\n  const { data } = usePkgGoVersionZip('golang.org/x/mod', 'v0.37.0');\n\n  return <p>{data?.byteLength} bytes</p>;\n}\n```\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n| `enabled` | `boolean` | `true` | Disable the query (also disabled when `modulePath` or `version` is empty) |\n| `queryOptions` | `QueryOverrides<TData>` | `undefined` | Override TanStack Query options (`staleTime`, `retry`, `gcTime`, `select`, etc.) |\n\n---\n\n## License\n\nMIT © [ElJijuna](https://github.com/ElJijuna)\n","readmeFilename":"README.md","_rev":"1-21310e382512c46ec0f1bed7e220d6b3"}