{"id":23639914,"url":"https://github.com/tsuki-lab/react-microcms-extension","last_synced_at":"2026-04-29T22:32:47.373Z","repository":{"id":57702087,"uuid":"501684171","full_name":"tsuki-lab/react-microcms-extension","owner":"tsuki-lab","description":"Custom Hook to create extension field for microCMS","archived":false,"fork":false,"pushed_at":"2022-06-09T15:24:58.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-19T10:05:57.126Z","etag":null,"topics":["microcms","react-hook","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-microcms-extension","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsuki-lab.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":null,"support":null}},"created_at":"2022-06-09T14:21:43.000Z","updated_at":"2022-07-12T04:43:16.000Z","dependencies_parsed_at":"2022-09-26T21:11:05.169Z","dependency_job_id":null,"html_url":"https://github.com/tsuki-lab/react-microcms-extension","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"tsuki-lab/use-microcms-iframe","purl":"pkg:github/tsuki-lab/react-microcms-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuki-lab%2Freact-microcms-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuki-lab%2Freact-microcms-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuki-lab%2Freact-microcms-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuki-lab%2Freact-microcms-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsuki-lab","download_url":"https://codeload.github.com/tsuki-lab/react-microcms-extension/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuki-lab%2Freact-microcms-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32446603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"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":["microcms","react-hook","typescript"],"created_at":"2024-12-28T08:29:05.677Z","updated_at":"2026-04-29T22:32:47.356Z","avatar_url":"https://github.com/tsuki-lab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-microcms-extension\n\n[![npm version](https://badge.fury.io/js/react-microcms-extension.svg)](https://badge.fury.io/js/react-microcms-extension)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThis library will help you create [microCMS extension fields](https://document.microcms.io/manual/field-extension) in React.\n\nThere are two types of custom hooks offered.\n\n- [useMicroCMSExtension](#usemicrocmsextension)\n- [useMicroCMSExtensionState](#usemicrocmsextensionstate)\n\n## Quick start\n\n```shell\nnpm install react-microcms-extension\n# or\nyarn add react-microcms-extension\n```\n\nUse simple.\n\n```tsx\nimport { useMicroCMSExtension } from 'react-microcms-extension'\n\nfunction App() {\n  const { state, post } = useMicroCMSExtension\u003cstring\u003e()\n\n  return (\n    \u003cinput\n      type=\"text\"\n      value={state?.message?.data ?? ''}\n      onChange={(e) =\u003e {\n        post({\n          description: e.target.value,\n          data: e.target.value,\n        })\n      }}\n    /\u003e\n  )\n}\n```\n\n# useMicroCMSExtension\n\n## Usage\n\n```tsx\nimport { useMicroCMSExtension } from 'react-microcms-extension'\n\nfunction App() {\n  const { state, post } = useMicroCMSExtension\u003cstring\u003e()\n\n  return (\n    \u003cinput\n      type=\"text\"\n      value={state?.message?.data ?? ''}\n      onChange={(e) =\u003e {\n        post({\n          description: e.target.value,\n          data: e.target.value,\n        })\n      }}\n    /\u003e\n  )\n}\n```\n\n## Description\n\n```ts\ntype State = {\n  // ...\n}\n\nconst options = {\n  height: 500,\n  origin: 'https://example.microcms.microcms.io',\n}\n\nconst { state, post, postState } = useMicroCMSExtension\u003cState\u003e(options)\n```\n\n### state\n\nThe state at the time of initialization can be handled.\n\n### post\n\nPOST data to microCMS. Calls `window.parent.postMessage` internally.\n\nPlease refer to the [microCMS documentation](https://document.microcms.io/manual/iframe-field#h7f543cc470) for the parameters that can be posted.\n\n### postState\n\nThe state of the result of executing the post() method.\nIt will contain information of action type `MICROCMS_POST_DATA_SUCCESS` or `MICROCMS_POST_DATA_FAILURE`.\n\n## Options\n\n| Key    | Type             | Default             | Description                                                            |\n| ------ | ---------------- | ------------------- | ---------------------------------------------------------------------- |\n| height | string \\| number | 300                 | height of the extended field                                           |\n| width  | string \\| number | '100%'              | width of the extended field                                            |\n| origin | string           | MessageEvent.origin | microCMS admin screen URL (https://\\\u003cserviceId\\\u003e.microcms.microcms.io) |\n\n# useMicroCMSExtensionState\n\nA custom hook that wraps `useMicroCMSExtension` so that it can be treated like `useState`.\n\n## Usage\n\n```tsx\nimport { useMicroCMSExtensionState } from 'react-microcms-extension'\n\nfunction App() {\n  const [state, setState] = useMicroCMSExtensionState('')\n\n  return (\n    \u003cinput\n      type=\"text\"\n      value={state}\n      onChange={(e) =\u003e setState(e.target.value)}\n    /\u003e\n  )\n}\n```\n\n## Description\n\n```ts\ntype State = {\n  // ...\n}\n\nconst initialState: State = {\n  // ...\n}\n\nconst options = {\n  height: 500,\n  origin: 'https://example.microcms.microcms.io',\n}\n\nconst [state, setState] = useMicroCMSExtensionState\u003cState\u003e(\n  initialState,\n  options\n)\n```\n\n## Options\n\nInherits `useMicroCMSExtension` options.\n\n### parsePostMessageParams\n\nparse MessageParams when postEvent to microCMS\n\n#### example\n\n```ts\ntype State = {\n  id: string\n  text: string\n}\n\nconst initialState: State = {\n  id: '',\n  text: ''\n}\n\nconst [state, setState] = useMicroCMSExtensionState\u003cState\u003e(initialState, {\n  parsePostMessageParams: (data) =\u003e ({\n    id: data.id\n    description: data.text,\n    data\n  }),\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuki-lab%2Freact-microcms-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsuki-lab%2Freact-microcms-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuki-lab%2Freact-microcms-extension/lists"}