{"id":43650644,"url":"https://github.com/code-wheel/jsonapi-frontend-client","last_synced_at":"2026-02-04T19:38:33.003Z","repository":{"id":331279440,"uuid":"1126017932","full_name":"code-wheel/jsonapi-frontend-client","owner":"code-wheel","description":"TypeScript client helpers for Drupal jsonapi_frontend","archived":false,"fork":false,"pushed_at":"2026-01-03T23:43:08.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-05T11:08:49.806Z","etag":null,"topics":["decoupled","drupal","headless","jsonapi","npm","typescript"],"latest_commit_sha":null,"homepage":"https://www.drupal.org/project/jsonapi_frontend","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-wheel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-31T22:08:57.000Z","updated_at":"2026-01-03T23:11:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/code-wheel/jsonapi-frontend-client","commit_stats":null,"previous_names":["codewheel-ai/jsonapi-frontend-client"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/code-wheel/jsonapi-frontend-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-wheel%2Fjsonapi-frontend-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-wheel%2Fjsonapi-frontend-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-wheel%2Fjsonapi-frontend-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-wheel%2Fjsonapi-frontend-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-wheel","download_url":"https://codeload.github.com/code-wheel/jsonapi-frontend-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-wheel%2Fjsonapi-frontend-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29094467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T19:16:55.479Z","status":"ssl_error","status_checked_at":"2026-02-04T19:16:52.508Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decoupled","drupal","headless","jsonapi","npm","typescript"],"created_at":"2026-02-04T19:38:32.145Z","updated_at":"2026-02-04T19:38:32.992Z","avatar_url":"https://github.com/code-wheel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@codewheel/jsonapi-frontend-client`\n\nTypeScript client helpers for Drupal `drupal/jsonapi_frontend`.\n\nThis package is **optional**. You can always call `/jsonapi/resolve` directly with `fetch()`.\n\n## Install\n\n```bash\nnpm i @codewheel/jsonapi-frontend-client\n```\n\n## Usage\n\nSet `DRUPAL_BASE_URL` (must be a full `http(s)://` URL), then:\n\n```ts\nimport { resolvePath, fetchJsonApi } from \"@codewheel/jsonapi-frontend-client\"\n\nconst resolved = await resolvePath(\"/about-us\")\nif (resolved.resolved \u0026\u0026 resolved.kind === \"entity\") {\n  const doc = await fetchJsonApi(resolved.jsonapi_url)\n  console.log(doc.data)\n}\n```\n\n## Layout Builder (optional)\n\nIf you install the `jsonapi_frontend_layout` add-on module, you can resolve a path and (when applicable) receive a normalized Layout Builder tree:\n\n```ts\nimport { resolvePathWithLayout, fetchJsonApi } from \"@codewheel/jsonapi-frontend-client\"\n\nconst resolved = await resolvePathWithLayout(\"/about-us\")\nif (resolved.resolved \u0026\u0026 resolved.kind === \"entity\") {\n  const doc = await fetchJsonApi(resolved.jsonapi_url)\n  if (resolved.layout) {\n    console.log(resolved.layout.sections)\n  }\n}\n```\n\n## Astro / Vite (`import.meta.env`)\n\n```ts\nimport { resolvePath, fetchJsonApi } from \"@codewheel/jsonapi-frontend-client\"\n\nconst baseUrl = import.meta.env.DRUPAL_BASE_URL\n\nconst resolved = await resolvePath(\"/about-us\", { baseUrl })\nif (resolved.resolved \u0026\u0026 resolved.kind === \"entity\") {\n  const doc = await fetchJsonApi(resolved.jsonapi_url, { baseUrl })\n}\n```\n\n## Authentication (optional)\n\nKeep credentials server-side. Pass headers via `options.headers`:\n\n```ts\nimport { resolvePath } from \"@codewheel/jsonapi-frontend-client\"\n\nconst baseUrl = process.env.DRUPAL_BASE_URL!\nconst auth = \"Basic \" + Buffer.from(`${process.env.DRUPAL_BASIC_USERNAME}:${process.env.DRUPAL_BASIC_PASSWORD}`).toString(\"base64\")\n\nawait resolvePath(\"/about-us\", {\n  baseUrl,\n  headers: { Authorization: auth },\n})\n```\n\n```ts\nimport { resolvePath } from \"@codewheel/jsonapi-frontend-client\"\n\nawait resolvePath(\"/about-us\", {\n  headers: { Authorization: `Bearer ${process.env.DRUPAL_JWT_TOKEN}` },\n})\n```\n\n### Caching note (Next.js / SSR)\n\nIf you pass `Authorization` (or `Cookie`) headers, this client defaults to `cache: \"no-store\"` unless you explicitly set `options.init.cache`.\n\n## Static builds (SSG) routes feed (optional)\n\nIf you enable the secret-protected routes feed in Drupal (`/jsonapi/routes`), you can fetch a complete build-time list of headless paths by following `links.next`:\n\n```ts\nimport { collectRoutes } from \"@codewheel/jsonapi-frontend-client\"\n\nconst baseUrl = process.env.DRUPAL_BASE_URL!\nconst secret = process.env.ROUTES_FEED_SECRET!\n\nconst routes = await collectRoutes({ baseUrl, secret })\nconst paths = routes.map((r) =\u003e r.path)\n```\n\nKeep `ROUTES_FEED_SECRET` server-side only (build environment variables). Do not expose it to browsers.\n\n## Menus (optional)\n\nIf you install the `jsonapi_frontend_menu` add-on module, you can fetch a ready-to-render tree:\n\n```ts\nimport { fetchMenu } from \"@codewheel/jsonapi-frontend-client\"\n\nconst menu = await fetchMenu(\"main\", { path: \"/about-us\" })\nconsole.log(menu.data)\n```\n\n## Query building (optional)\n\nThis client doesn’t require a query builder, but `drupal-jsonapi-params` works well:\n\n```ts\nimport { DrupalJsonApiParams } from \"drupal-jsonapi-params\"\nimport { fetchJsonApi } from \"@codewheel/jsonapi-frontend-client\"\n\nconst baseUrl = process.env.DRUPAL_BASE_URL!\n\nconst params = new DrupalJsonApiParams()\n  .addFilter(\"status\", \"1\")\n  .addFields(\"node--article\", [\"title\", \"path\", \"body\"])\n\nconst url = `/jsonapi/node/article?${params.getQueryString()}`\nawait fetchJsonApi(url, { baseUrl })\n```\n\n## URL safety (recommended)\n\nBy default, `fetchJsonApi()` and `fetchView()` refuse to fetch absolute URLs on a different origin than your `DRUPAL_BASE_URL` (to avoid accidental SSRF in server environments).\n\nIf you intentionally need to fetch a cross-origin absolute URL, pass `allowExternalUrls: true`:\n\n```ts\nimport { fetchJsonApi } from \"@codewheel/jsonapi-frontend-client\"\n\nawait fetchJsonApi(\"https://cms.example.com/jsonapi/node/page/...\", {\n  allowExternalUrls: true,\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-wheel%2Fjsonapi-frontend-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-wheel%2Fjsonapi-frontend-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-wheel%2Fjsonapi-frontend-client/lists"}