{"_id":"@am25/plank-client","_rev":"3-efb898a76b2d9e5860b5e18041861761","name":"@am25/plank-client","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@am25/plank-client","version":"0.1.0","keywords":["cms","headless-cms","plank","plank-cms","next","astro","client","am25"],"author":{"url":"https://alemartir.com","name":"Alejandro Mártir"},"license":"MIT","_id":"@am25/plank-client@0.1.0","maintainers":[{"name":"itsmrtr","email":"hola@alemartir.com"}],"homepage":"https://github.com/am25-labs/plank-client#readme","bugs":{"url":"https://github.com/am25-labs/plank-client/issues"},"dist":{"shasum":"cbe965f2e9cd2087efe0f4d1704eca5e6a09784a","tarball":"https://registry.npmjs.org/@am25/plank-client/-/plank-client-0.1.0.tgz","fileCount":23,"integrity":"sha512-sMnDaIqjmmrXx4xfrJD5AczaEv6KZcsp7tReWbYONzuCBbVWrT1dANfFc3HIhaCV8kg2urdHGQjg0YOWsU4p0A==","signatures":[{"sig":"MEUCIHzt1qifJ8k8hZ8kOfijLw6DuJ30wfIIhLg3LhIOTwtiAiEA8N+eA6QvpqTNoppz4fSqf/i4jDIzknsR+Y/iACICCN8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@am25%2fplank-client@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":15973},"main":"dist/index.js","type":"module","_from":"file:am25-plank-client-0.1.0.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","lint":"eslint src/","build":"tsc"},"_npmUser":{"name":"itsmrtr","email":"hola@alemartir.com"},"_resolved":"/tmp/ec798873cd20309b5996ceefb9b9c38b/am25-plank-client-0.1.0.tgz","_integrity":"sha512-sMnDaIqjmmrXx4xfrJD5AczaEv6KZcsp7tReWbYONzuCBbVWrT1dANfFc3HIhaCV8kg2urdHGQjg0YOWsU4p0A==","repository":{"url":"git+https://github.com/am25-labs/plank-client.git","type":"git"},"_npmVersion":"10.8.2","description":"Client for the Plank CMS headless API.","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/plank-client_0.1.0_1777154238086_0.24392330817967922","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Plank Client moved to @plank-cms/client. Please install @plank-cms/client instead."},"0.2.0":{"name":"@am25/plank-client","version":"0.2.0","keywords":["cms","headless-cms","plank","plank-cms","next","astro","client","am25"],"author":{"url":"https://alemartir.com","name":"Alejandro Mártir"},"license":"MIT","_id":"@am25/plank-client@0.2.0","maintainers":[{"name":"itsmrtr","email":"hola@alemartir.com"}],"homepage":"https://github.com/am25-labs/plank-client#readme","bugs":{"url":"https://github.com/am25-labs/plank-client/issues"},"dist":{"shasum":"d96cd84f0aba358495a893804d0e45e24626bce2","tarball":"https://registry.npmjs.org/@am25/plank-client/-/plank-client-0.2.0.tgz","fileCount":23,"integrity":"sha512-U3UEOAaLc9k7tmFhB6vIa1k0atEkw/AMTErXffJ9RVUo3FYria5/luMRM/2iB66Cx74onx9ydw9qsUdBmrrvFA==","signatures":[{"sig":"MEQCIEM2Pn3UdaMAaMGXp0Js9pJkDAtsb8Tg2RZhOVSW0RbrAiASU8N+ogv/eJ0b0u26+zx/IIoHsrEvpgHHvKtxn5SFTA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@am25%2fplank-client@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":17493},"main":"dist/index.js","type":"module","_from":"file:am25-plank-client-0.2.0.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsc --watch","lint":"eslint src/","build":"tsc"},"_npmUser":{"name":"itsmrtr","email":"hola@alemartir.com"},"_resolved":"/tmp/0f0f8442e88624d588270c1414e7adc2/am25-plank-client-0.2.0.tgz","_integrity":"sha512-U3UEOAaLc9k7tmFhB6vIa1k0atEkw/AMTErXffJ9RVUo3FYria5/luMRM/2iB66Cx74onx9ydw9qsUdBmrrvFA==","repository":{"url":"git+https://github.com/am25-labs/plank-client.git","type":"git"},"_npmVersion":"10.8.2","description":"Client for the Plank CMS headless API.","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/plank-client_0.2.0_1777358957592_0.8647118589467082","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Plank Client moved to @plank-cms/client. Please install @plank-cms/client instead."}},"time":{"created":"2026-04-25T21:57:17.971Z","modified":"2026-05-01T00:11:46.926Z","0.1.0":"2026-04-25T21:57:18.230Z","0.2.0":"2026-04-28T06:49:17.716Z"},"bugs":{"url":"https://github.com/am25-labs/plank-client/issues"},"author":{"url":"https://alemartir.com","name":"Alejandro Mártir"},"license":"MIT","homepage":"https://github.com/am25-labs/plank-client#readme","keywords":["cms","headless-cms","plank","plank-cms","next","astro","client","am25"],"repository":{"url":"git+https://github.com/am25-labs/plank-client.git","type":"git"},"description":"Client for the Plank CMS headless API.","maintainers":[{"name":"itsmrtr","email":"hola@alemartir.com"}],"readme":"# Plank CMS - Client\n\nClient for the [Plank CMS](https://github.com/am25-labs/plank-cms) headless API. Works with Next.js App Router, Astro, or any React project.\n\n## Installation\n\n```bash\npnpm add @am25/plank-client\n```\n\n## Setup\n\nCreate a client instance and export it for reuse across your project:\n\n```ts\n// lib/plank.ts\nimport { createPlankClient } from \"@am25/plank-client\";\n\nconst plank = createPlankClient({\n  url: process.env.PLANK_URL!,\n  token: process.env.PLANK_TOKEN!,\n  // optional: attach a default locale to all public API requests when not overridden\n  // defaultLocale: 'en',\n});\n\nexport default plank;\n```\n\n```bash\n# .env.local\nPLANK_URL=https://your-plank-instance.com\nPLANK_TOKEN=plank_a1b2c3d4...\n```\n\n## Usage\n\n### Collections\n\nFetch a list of entries from a collection type:\n\n```ts\nimport plank from \"@/lib/plank\";\n\nconst { data, total, page, limit } = await plank.collection(\"posts\").findMany();\n```\n\nWith params:\n\n```ts\nconst { data } = await plank.collection(\"posts\").findMany({\n  page: 1,\n  limit: 9,\n  status: \"published\",\n  // any field defined in your content type works as an equality filter\n  category: \"news\",\n});\n```\n\nLocale / per-request override:\n\n```ts\n// if you configured a `defaultLocale` on the client, you can still override it per-request\nconst { data: esPosts } = await plank\n  .collection(\"posts\")\n  .findMany({ locale: \"es\" });\nconst { data: frPosts } = await plank\n  .collection(\"posts\")\n  .findMany({ locale: \"fr\" });\n```\n\nFetch a single entry by ID:\n\n```ts\nconst post = await plank.collection(\"posts\").findOne(\"entry-id\");\n```\n\n### Single Types\n\n```ts\nconst homepage = await plank.single(\"homepage\").find();\n```\n\n### Drafts\n\n```ts\nconst draft = await plank\n  .collection(\"posts\")\n  .findOne(\"entry-id\", { cache: \"no-store\" });\n// or with status\nconst drafts = await plank\n  .collection(\"posts\")\n  .findMany({ status: \"draft\" }, { cache: \"no-store\" });\n```\n\n---\n\n## Next.js App Router cache\n\nThe client integrates natively with Next.js `fetch` cache options.\n\n### Static (default)\n\nData cached indefinitely. Ideal for content that rarely changes.\n\n```ts\nawait plank.collection(\"posts\").findMany();\n// equivalent to fetch(..., { cache: 'force-cache' })\n```\n\n### ISR — Incremental Static Regeneration\n\nRevalidate on a time interval:\n\n```ts\n// revalidate every 10 minutes\nawait plank.collection(\"posts\").findMany({}, { revalidate: 600 });\n\n// revalidate every 24 hours\nawait plank.single(\"homepage\").find({}, { revalidate: 86400 });\n```\n\n### No cache\n\nAlways fetch fresh data. Useful for previews or highly dynamic content:\n\n```ts\nawait plank.collection(\"posts\").findMany({}, { cache: \"no-store\" });\n```\n\n---\n\n## TypeScript\n\nThe client is fully typed. Pass your content type interface as a generic to get typed responses:\n\n```ts\ninterface Post {\n  id: string;\n  title: string;\n  slug: string;\n  body: string;\n  cover: { url: string };\n  published_at: string;\n}\n\nconst { data } = await plank.collection<Post>(\"posts\").findMany();\n// data is Post[]\n\nconst post = await plank.collection<Post>(\"posts\").findOne(\"entry-id\");\n// post is Post\n```\n\n---\n\n## Query params reference\n\n| Param         | Type                              | Default       | Description                                                   |\n| ------------- | --------------------------------- | ------------- | ------------------------------------------------------------- |\n| `page`        | `number`                          | `1`           | Page number                                                   |\n| `limit`       | `number`                          | `20`          | Entries per page (max 100)                                    |\n| `status`      | `'published' \\| 'draft' \\| 'all'` | `'published'` | Filter by status                                              |\n| `sort`        | `string`                          | —             | Field name to sort by                                         |\n| `order`       | `'asc' \\| 'desc'`                 | —             | Sort direction                                                |\n| `[fieldname]` | `string \\| number`                | —             | Equality filter on any content type field                     |\n| `locale`      | `string`                          | —             | Request a localized version of localizable fields (e.g. `es`) |\n\n---\n\n## Low-level API\n\nFor full control, use `fetch` and `buildUrl` directly:\n\n```ts\n// raw fetch\nconst data = await plank.fetch(\"/posts\", { limit: 5 }, { revalidate: 300 });\n\n// build URL without fetching (useful for debugging or custom fetch logic)\nconst url = plank.buildUrl(\"/posts\", { category: \"news\", limit: 10 });\n// https://your-plank-instance.com/api/posts?category=news&limit=10\n```\n\n---\n\n## License\n\n[MIT](LICENSE) - AM25, S.A.S. DE C.V.\n","readmeFilename":"README.md"}