{"_id":"@avovix/astro-loader-payload","_rev":"4-76187750813c304e8c6d907d02422c4e","name":"@avovix/astro-loader-payload","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@avovix/astro-loader-payload","version":"0.1.0","keywords":["withastro","astro-loader","payload","payloadcms","cms","content-layer","loader"],"author":{"url":"https://avovix.com","name":"Stephen Covell","email":"stephen@sledgehammer.dev"},"license":"MIT","_id":"@avovix/astro-loader-payload@0.1.0","maintainers":[{"name":"stephencovell","email":"stephen.covell@avovix.com"}],"homepage":"https://github.com/avovix/bridge/tree/main/packages/astro-loader-payload#readme","bugs":{"url":"https://github.com/avovix/bridge/issues"},"dist":{"shasum":"d97b1d1d7eb9e7ffd8d0cd20aa45a09d7475e5df","tarball":"https://registry.npmjs.org/@avovix/astro-loader-payload/-/astro-loader-payload-0.1.0.tgz","fileCount":17,"integrity":"sha512-fGQOt9xVVZAiBn9oMhMF7wLrivW0rI8PtFsegWAQ9eeX1A0IU07FCam14Tp2NkQDrVr/KCjKa2+vN8iMDiBlmg==","signatures":[{"sig":"MEUCIQCBi1FAQdgPsS+Ltp/OTSeI7+q6TCre2c1JNKpDMnItLwIgAqxFZFGyD1v91JMZTq6ESAL8K7YY7sI8k9xyD1X+XV4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16422},"main":"./dist/index.js","type":"module","_from":"file:avovix-astro-loader-payload-0.1.0.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"dev":"tsc --watch","build":"tsc --build","typecheck":"tsc --noEmit"},"_npmUser":{"name":"stephencovell","email":"stephen.covell@avovix.com"},"_resolved":"/private/var/folders/fc/ljgftmcj2pb_0srqb1mw5ztr0000gn/T/978d7c7847bed818c350ab90bc67efcd/avovix-astro-loader-payload-0.1.0.tgz","_integrity":"sha512-fGQOt9xVVZAiBn9oMhMF7wLrivW0rI8PtFsegWAQ9eeX1A0IU07FCam14Tp2NkQDrVr/KCjKa2+vN8iMDiBlmg==","repository":{"url":"git+https://github.com/avovix/bridge.git","type":"git","directory":"packages/astro-loader-payload"},"_npmVersion":"10.9.2","description":"Astro content layer loader for Payload CMS — build-time and live collections, fully typed.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"astro":"^7","payload":"^3","typescript":"^6.0.3","@payloadcms/sdk":"^3"},"peerDependencies":{"astro":"^7","payload":"^3","@payloadcms/sdk":"^3"},"peerDependenciesMeta":{"@payloadcms/sdk":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/astro-loader-payload_0.1.0_1783373907932_0.8938536607773973","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@avovix/astro-loader-payload","version":"0.2.0","keywords":["withastro","astro-loader","payload","payloadcms","cms","content-layer","loader"],"author":{"url":"https://avovix.com","name":"Stephen Covell","email":"stephen@sledgehammer.dev"},"license":"MIT","_id":"@avovix/astro-loader-payload@0.2.0","maintainers":[{"name":"stephencovell","email":"stephen.covell@avovix.com"}],"homepage":"https://github.com/avovix/bridge/tree/main/packages/astro-loader-payload#readme","bugs":{"url":"https://github.com/avovix/bridge/issues"},"dist":{"shasum":"c843b9a810f1ee0ba41850af3b1e11dda38ed8b2","tarball":"https://registry.npmjs.org/@avovix/astro-loader-payload/-/astro-loader-payload-0.2.0.tgz","fileCount":21,"integrity":"sha512-nWSEN7vdY2gSnhCsq5GkGKF/mi+TWftsa+4ff0dVIFRLdv1mUbs5lDTwIES8aJhw9SPr5+RimmJBhOUsSD4bOQ==","signatures":[{"sig":"MEUCIQDyljnrG0qOmpOIKS8E8EaK8rRr9FENPwjKbcmJKKqikQIgcF4FMLqQIu0EtriBQ485n2xbngK5bBbZECKfetYIA9s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17668},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./mock":{"types":"./dist/adapters/index.d.ts","import":"./dist/adapters/index.js"}},"gitHead":"8159ca52fda08f2b29d4aa9fb80bc36184b412db","scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc --build","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage","prepublishOnly":"pnpm build"},"_npmUser":{"name":"stephencovell","email":"stephen.covell@avovix.com"},"repository":{"url":"git+https://github.com/avovix/bridge.git","type":"git","directory":"packages/astro-loader-payload"},"_npmVersion":"10.9.2","description":"Astro content layer loader for PayloadCMS, with build-time and live collections and full typed.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.24.0","devDependencies":{"astro":"^7","vitest":"4.0.18","payload":"^3","typescript":"^6.0.3","@payloadcms/sdk":"^3","@vitest/coverage-v8":"4.0.18"},"peerDependencies":{"astro":"^7","payload":"^3","@payloadcms/sdk":"^3"},"peerDependenciesMeta":{"@payloadcms/sdk":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/astro-loader-payload_0.2.0_1783476821098_0.9086374494451532","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@avovix/astro-loader-payload","version":"0.3.0","keywords":["withastro","astro-loader","payload","payloadcms","cms","content-layer","loader"],"author":{"url":"https://avovix.com","name":"Stephen Covell","email":"stephen@sledgehammer.dev"},"license":"MIT","_id":"@avovix/astro-loader-payload@0.3.0","maintainers":[{"name":"stephencovell","email":"stephen.covell@avovix.com"}],"homepage":"https://github.com/avovix/bridge/tree/main/packages/astro-loader-payload#readme","bugs":{"url":"https://github.com/avovix/bridge/issues"},"dist":{"shasum":"61cebdea41c142950a71819ab62efdac5b2e6493","tarball":"https://registry.npmjs.org/@avovix/astro-loader-payload/-/astro-loader-payload-0.3.0.tgz","fileCount":29,"integrity":"sha512-Sm+5prfNabUhBvOjLxeAZ5zFvLZB0NxE8CYtDqhIM4lBKEGNxITVcP+O2LRHcVkEQ3RhXq36OgLEoSET7k1x+g==","signatures":[{"sig":"MEUCIQD1OvhlPGCkhciDMRY8P3IS1pVxeSxLFFcZD9YxnqTOkwIgFED8jWrcpby3UVc+GOaK8+Rhd9oD8+BJIXXwaTw/GpY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27761},"main":"./dist/index.js","type":"module","_from":"file:avovix-astro-loader-payload-0.3.0.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./mock":{"types":"./dist/adapters/index.d.ts","import":"./dist/adapters/index.js"}},"scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc --build","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"stephencovell","email":"stephen.covell@avovix.com"},"_resolved":"/private/var/folders/fc/ljgftmcj2pb_0srqb1mw5ztr0000gn/T/a995b690bf9b9823674055449c006743/avovix-astro-loader-payload-0.3.0.tgz","_integrity":"sha512-Sm+5prfNabUhBvOjLxeAZ5zFvLZB0NxE8CYtDqhIM4lBKEGNxITVcP+O2LRHcVkEQ3RhXq36OgLEoSET7k1x+g==","repository":{"url":"git+https://github.com/avovix/bridge.git","type":"git","directory":"packages/astro-loader-payload"},"_npmVersion":"10.9.2","description":"Astro content layer loader for PayloadCMS, with build-time and live collections and full typed.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"astro":"^7","vitest":"4.0.18","payload":"^3","typescript":"^6.0.3","@payloadcms/sdk":"^3","@vitest/coverage-v8":"4.0.18"},"peerDependencies":{"astro":"^7","payload":"^3","@payloadcms/sdk":"^3"},"peerDependenciesMeta":{"@payloadcms/sdk":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/astro-loader-payload_0.3.0_1783601541794_0.3196165527689365","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@avovix/astro-loader-payload","version":"0.4.0","description":"Astro content layer loader for PayloadCMS, with build-time and live collections and full typed.","keywords":["withastro","astro-loader","payload","payloadcms","cms","content-layer","loader"],"author":{"name":"Stephen Covell","email":"stephen@sledgehammer.dev","url":"https://avovix.com"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./mock":{"types":"./dist/adapters/index.d.ts","import":"./dist/adapters/index.js"}},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/avovix/bridge.git","directory":"packages/astro-loader-payload"},"homepage":"https://github.com/avovix/bridge/tree/main/packages/astro-loader-payload#readme","bugs":{"url":"https://github.com/avovix/bridge/issues"},"devDependencies":{"@payloadcms/sdk":"^3","@vitest/coverage-v8":"4.0.18","astro":"^7","payload":"^3","typescript":"^6.0.3","vitest":"4.0.18"},"peerDependencies":{"@payloadcms/sdk":"^3","astro":"^7","payload":"^3"},"peerDependenciesMeta":{"@payloadcms/sdk":{"optional":true}},"scripts":{"build":"tsc --build","dev":"tsc --watch","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_id":"@avovix/astro-loader-payload@0.4.0","_integrity":"sha512-ma8siJ5h9c4ZiLSSfNH673UUAy2dFK/E1aIUw0eonXMVpBvAlStwcN5xKItGy1X3orHyVEiOt8tepzO53rvVhg==","_resolved":"/private/var/folders/fc/ljgftmcj2pb_0srqb1mw5ztr0000gn/T/298748b1972fb3e3d3a5bf94994cb615/avovix-astro-loader-payload-0.4.0.tgz","_from":"file:avovix-astro-loader-payload-0.4.0.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ma8siJ5h9c4ZiLSSfNH673UUAy2dFK/E1aIUw0eonXMVpBvAlStwcN5xKItGy1X3orHyVEiOt8tepzO53rvVhg==","shasum":"8b8afd537cb94a35f240f342fc1c130f004bd07f","tarball":"https://registry.npmjs.org/@avovix/astro-loader-payload/-/astro-loader-payload-0.4.0.tgz","fileCount":31,"unpackedSize":30176,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCFAOhtEzmGwr53DCdXMQNoYNQqys0NuRl39Sc5fYGQ9AIgfb7F0jUZdDJtgQuGgAAZC/Gk69jri8pM7CJBLzNsivo="}]},"_npmUser":{"name":"stephencovell","email":"stephen.covell@avovix.com"},"directories":{},"maintainers":[{"name":"stephencovell","email":"stephen.covell@avovix.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/astro-loader-payload_0.4.0_1783609416525_0.06013468458349669"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T21:38:27.846Z","modified":"2026-07-09T15:03:37.056Z","0.1.0":"2026-07-06T21:38:28.069Z","0.2.0":"2026-07-08T02:13:41.287Z","0.3.0":"2026-07-09T12:52:21.929Z","0.4.0":"2026-07-09T15:03:36.821Z"},"bugs":{"url":"https://github.com/avovix/bridge/issues"},"author":{"name":"Stephen Covell","email":"stephen@sledgehammer.dev","url":"https://avovix.com"},"license":"MIT","homepage":"https://github.com/avovix/bridge/tree/main/packages/astro-loader-payload#readme","keywords":["withastro","astro-loader","payload","payloadcms","cms","content-layer","loader"],"repository":{"type":"git","url":"git+https://github.com/avovix/bridge.git","directory":"packages/astro-loader-payload"},"description":"Astro content layer loader for PayloadCMS, with build-time and live collections and full typed.","maintainers":[{"name":"stephencovell","email":"stephen.covell@avovix.com"}],"readme":"# @avovix/astro-loader-payload\n\nAn [Astro content layer](https://docs.astro.build/en/guides/content-collections/) loader for [Payload CMS](https://payloadcms.com).\n\nLoad your Payload collections into Astro's content layer and query them with `getCollection` and `getEntry`, just like any other Astro collection.\n\n> **Alpha.** This is a new package. The API may change before `1.0`. Feedback and issues welcome.\n\n## Status & feedback\n\nThis is an early release and fuller documentation is on the way. It is an\nopen-source project and I want it to fit as many real-world setups as possible,\nso if something is missing, unclear, or doesn't fit your use case, please\n[open a discussion](https://github.com/avovix/bridge/discussions) or an\n[issue](https://github.com/avovix/bridge/issues).\n\n## Why this loader\n\n- **Fully typed:** `collection`, `idField`, and query options are typed against your own Payload `Config`, so you get autocomplete and type-checking for your collections and fields directly in `content.config.ts` and `live.config.ts`.\n- **Uses your own Payload client:** you pass in the client you already configured (the SDK for REST, or a Payload instance for the Local API), so it always matches your Payload version and you keep the full range of client options without waiting on this package to expose them. SDK and Local API adapters are supported now, with GraphQL planned.\n- **Build-time and live:** covers static content collections and live (on-demand) collections.\n- **Full query passthrough:** anything Payload's find supports (`where`, `sort`, `depth`, `locale`, `draft`, and more) is passed straight through, not limited to a fixed set of options.\n- **Typed errors:** failures come through as typed errors with a stable `code`, a `hint`, and a `static is()` guard, so you can identify and handle them precisely instead of matching on message strings.\n\nA complete, runnable setup lives in the [`astro-payload-with-sdk` example](../../examples/astro-payload-with-sdk).\n\n## Install\n\n```sh\npnpm add @avovix/astro-loader-payload\n# peers you likely already have:\npnpm add payload @payloadcms/sdk\n```\n\n`payload` and `astro` are required peer dependencies. `@payloadcms/sdk` is an optional peer, needed only if you use the SDK adapter.\n\n## Quick start\n\nBuild your Payload SDK client, wrap it in the SDK adapter, and pass it to the loader:\n\n```ts\n// src/content.config.ts\nimport { defineCollection } from 'astro:content'\nimport { payloadCollectionLoader, payloadSdkAdapter } from '@avovix/astro-loader-payload'\nimport { PayloadSDK } from '@payloadcms/sdk'\nimport type { Config } from './payload-types' // your generated Payload types\n\nconst sdk = new PayloadSDK<Config>({\n  baseURL: import.meta.env.PAYLOAD_BASE_URL, // e.g. http://localhost:3000/api\n})\n\nconst posts = defineCollection({\n  loader: payloadCollectionLoader({\n    adapter: payloadSdkAdapter(sdk),\n    collection: 'posts',\n  }),\n})\n\nexport const collections = { posts }\n```\n\nThen query it in a page like any Astro collection:\n\n```astro\n---\nimport { getCollection } from 'astro:content'\nconst posts = await getCollection('posts')\n---\n<ul>\n  {posts.map((post) => (\n    <li><a href={`/post/${post.data.slug}/`}>{post.data.title}</a></li>\n  ))}\n</ul>\n```\n\nThe loader populates the content store; your pages never touch Payload directly.\n\n## Adapters\n\nThe loader talks to Payload through an adapter. You build the client and pass it\nin, so the loader stays decoupled from how you connect.\n\n### SDK adapter (REST)\n\nBest when Astro and Payload are deployed separately. You give it a configured\n`PayloadSDK` client (as shown in the quick start):\n\n```ts\nimport { payloadSdkAdapter } from '@avovix/astro-loader-payload'\nimport { PayloadSDK } from '@payloadcms/sdk'\n\nconst sdk = new PayloadSDK<Config>({ baseURL: import.meta.env.PAYLOAD_BASE_URL })\n\npayloadCollectionLoader({ adapter: payloadSdkAdapter(sdk), collection: 'posts' })\n```\n\n### Local API adapter\n\nBest when Astro and Payload run together (for example, in the same monorepo).\nIt uses Payload's Local API in-process, so there is no HTTP server to run. You\ngive it a Payload instance:\n\n```ts\nimport { getPayload } from 'payload'\nimport config from './payload.config'\nimport { payloadLocalAdapter } from '@avovix/astro-loader-payload'\n\nconst payload = await getPayload({ config })\n\npayloadCollectionLoader({ adapter: payloadLocalAdapter(payload), collection: 'posts' })\n```\n\n### Local for dev, SDK for deploy\n\nBecause both adapters satisfy the same interface, you can switch between them\nwithout changing the rest of your loader setup, for example using the Local API\nlocally and the SDK in a decoupled deployment:\n\n```ts\nconst adapter = import.meta.env.DEV\n  ? payloadLocalAdapter(await getPayload({ config }))\n  : payloadSdkAdapter(new PayloadSDK<Config>({ baseURL: import.meta.env.PAYLOAD_BASE_URL }))\n\npayloadCollectionLoader({ adapter, collection: 'posts' })\n```\n\nThe Local API adapter needs your Payload config and database available at build\ntime, which suits co-located setups; the SDK adapter works whenever a running\nPayload API is reachable.\n\n## Adding a schema\n\nThe loader works without a schema, but defining one gives you validated, fully\ntyped `.data` in your pages (the standard Astro content collections feature).\nPass a Zod schema to `defineCollection` as usual:\n\n```ts\nimport { defineCollection, z } from 'astro:content'\nimport { payloadCollectionLoader, payloadSdkAdapter } from '@avovix/astro-loader-payload'\n\nconst posts = defineCollection({\n  loader: payloadCollectionLoader({\n    adapter: payloadSdkAdapter(sdk),\n    collection: 'posts',\n  }),\n  schema: z.object({\n    title: z.string(),\n    slug: z.string(),\n    excerpt: z.string().optional(),\n  }),\n})\n```\n\nNow `post.data` is typed as `{ title: string; slug: string; excerpt?: string }`\nin your pages. If you would rather store the raw Payload document without\nvalidation, pass `skipValidation: true` in the loader options instead.\n\n## Options\n\n```ts\npayloadCollectionLoader({\n  adapter,             // required. A Payload adapter (see below).\n  collection,      // required. The collection to load, e.g. 'posts'.\n\n  skipValidation,      // optional. Skip Astro schema validation of each entry.\n  loaderName,          // optional. Log name (defaults to the slug; null to disable).\n  idField,             // optional. Which field becomes the entry id (default: 'id').\n  query,               // optional. where / sort / limit / depth / locale / draft, and more.\n})\n```\n\n### `idField`\n\nBy default entries are keyed by the Payload document `id`. Set `idField` to key them by another field so you can look them up directly:\n\n```ts\npayloadCollectionLoader({\n  adapter: payloadSdkAdapter(sdk),\n  collection: 'posts',\n  idField: 'slug', // now getEntry('posts', 'my-slug') works\n})\n```\n\nIf you use a custom `idField`, make sure that field is unique on the collection.\n\n### `query`\n\nAnything you can pass to a Payload find is passed straight through:\n\n```ts\npayloadCollectionLoader({\n  adapter: payloadSdkAdapter(sdk),\n  collection: 'posts',\n  query: {\n    where: { _status: { equals: 'published' } },\n    sort: '-createdAt',\n    depth: 1,\n  },\n})\n```\n\n## Live collections\n\nFor always-fresh data (SSR / on-demand rendering), use the live loader with a\n`live.config.ts` and query it with `getLiveCollection` / `getLiveEntry`.\n\n```ts\n// src/live.config.ts\nimport { defineLiveCollection } from 'astro:content'\nimport { payloadLiveCollectionLoader, payloadSdkAdapter } from '@avovix/astro-loader-payload'\nimport { PayloadSDK } from '@payloadcms/sdk'\nimport type { Config } from './payload-types'\n\nconst sdk = new PayloadSDK<Config>({ baseURL: import.meta.env.PAYLOAD_BASE_URL })\n\nconst posts = defineLiveCollection({\n  loader: payloadLiveCollectionLoader({\n    adapter: payloadSdkAdapter(sdk),\n    collection: 'posts',\n  }),\n})\n\nexport const collections = { posts }\n```\n\nUnlike the build-time loader (which takes a `query` option), the live loader\nreceives a **`filter`** per request. It has the same shape as `query` and is\npassed at call time through `getLiveCollection` / `getLiveEntry`:\n\n```ts\nimport { getLiveCollection, getLiveEntry } from 'astro:content'\n\n// filter a live collection\nconst { entries } = await getLiveCollection('posts', {\n  where: { _status: { equals: 'published' } },\n  sort: '-createdAt',\n})\n\n// fetch a single live entry by id (or your idField)\nconst { entry } = await getLiveEntry('posts', { id: Astro.params.slug })\n```\n\nLive collections require an adapter configured for on-demand rendering and do not\nuse the build-time content store.\n\n## Error handling\n\nFailures produce typed errors so you can identify and handle them precisely. How\nan error is delivered depends on the loader:\n\n- **Build loader** (`load`) **throws** a `PayloadLoaderError`. It surfaces in\n  Astro's error overlay with a message and hint, and fails the build, which is the\n  correct behaviour for build-time content.\n- **Live loader** (`loadCollection` / `loadEntry`) **returns** `{ error }` (a\n  `PayloadLiveError`) instead of throwing, so a request can fail without crashing\n  the page.\n\nA **missing live entry returns `undefined`, not an error** — \"not found\" is a\nnormal result, so `getLiveEntry` returns `undefined` and your page can render a\n404 or fallback. An error is only returned when something is actually wrong (a\nfailed fetch, or a non-unique `idField`).\n\n### Error codes\n\nEvery error carries a stable `code`. Branch on the `code`, not the message text\n(the code is stable; messages may be reworded).\n\n| Code | Fires when | Loader | Delivered as |\n| --- | --- | --- | --- |\n| `PAYLOAD_FETCH_FAILED` | Fetching a collection fails (network, auth, API down) | build + live (`loadCollection`) | thrown (build) / `{ error }` (live) |\n| `PAYLOAD_ENTRY_FETCH_FAILED` | Fetching a single entry fails | live (`loadEntry`) | `{ error }` |\n| `PAYLOAD_VALIDATION_FAILED` | A document fails Astro schema validation | build | thrown |\n| `PAYLOAD_NON_UNIQUE_ID_FIELD` | A custom `idField` matches more than one document | live (`loadEntry`) | `{ error }` |\n\nFor the live loader, `loadEntry` also returns `undefined` (no error) when no\ndocument matches the requested id.\n\n### Working with errors\n\nBoth error types carry a `code`, a `hint`, and (where available) the original\n`cause`, and expose a `static is()` guard for safe narrowing:\n\n```ts\nimport { getLiveEntry } from 'astro:content'\nimport { PayloadLiveError } from '@avovix/astro-loader-payload'\nimport type { PayloadErrorCode } from '@avovix/astro-loader-payload'\n\nconst { entry, error } = await getLiveEntry('posts', { id })\n\nif (error && PayloadLiveError.is(error)) {\n  // `error` is now typed as PayloadLiveError\n  if (error.code === ('PAYLOAD_ENTRY_FETCH_FAILED' satisfies PayloadErrorCode)) {\n    // handle a fetch failure\n  }\n}\n```\n\nPrefer `PayloadLiveError.is(error)` / `PayloadLoaderError.is(error)` over\n`instanceof`, and branch on `error.code` rather than the message text (the code\nis stable; messages may be reworded).\n\n## Using Payload types in your Astro app (monorepo)\n\nIf Payload and Astro live in the same monorepo, expose your Payload config and\ngenerated types from the CMS package so the Astro app can import `Config`:\n\n```ts\n// cms/src/index.ts\nexport { default as config } from './payload.config'\nexport * from './payload-types'\n```\n\n```jsonc\n// cms/package.json\n\"exports\": {\n  \".\": {\n    \"import\": \"./src/index.ts\",\n    \"types\": \"./src/index.ts\",\n    \"default\": \"./src/index.ts\"\n  }\n}\n```\n\n## Known limitations & gotchas\n\n- **Alpha:** API may change before `1.0`.\n- **Entry limit:** the loader fetches up to 1000 entries per collection by default. Pass `query.limit` to change it. Full pagination traversal is planned.\n- **HMR in dev:** due to [an Astro limitation](https://github.com/withastro/astro/issues/13253), define your collections directly in `content.config.ts` rather than in a separate imported file, or HMR may not pick up changes.\n- **Empty on first run:** if a collection appears empty when you first start the dev server, trigger a content sync with `s` + Enter, or restart the server.\n- **GraphQL adapter planned:** SDK (REST) and Local API adapters are supported; a GraphQL adapter is planned.\n\n## License\n\nMIT © Avovix\n","readmeFilename":"README.md"}