{"_id":"@kaliber/use-global-page-state","_rev":"38-9bf6da28d6dc57d38d648ed6b5fd7bb1","name":"@kaliber/use-global-page-state","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@kaliber/use-global-page-state","version":"1.0.0","keywords":["react","global state","state"],"license":"MIT","_id":"@kaliber/use-global-page-state@1.0.0","maintainers":[{"name":"hjsielcken","email":"hsielcken@kaliber.net"},{"name":"rmostertkaliber","email":"rmostert@kaliber.net"},{"name":"kaliber-owner","email":"development@kaliber.net"},{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"},{"name":"pkuepers","email":"pkuepers@kaliber.net"},{"name":"larsvankleef","email":"spamlabtap@gmail.com"}],"dist":{"shasum":"d2678e7dad4558fc98e5f99356706f6f295c9c4e","tarball":"https://registry.npmjs.org/@kaliber/use-global-page-state/-/use-global-page-state-1.0.0.tgz","fileCount":7,"integrity":"sha512-jODWXcGKcZVUnidj5JNyswnZeAZnLYJbW/E7e2Lcxc+YLvVuYNJOpD5ya/DMx2P9fzacJo5z7vZsOpxjNqS5sw==","signatures":[{"sig":"MEYCIQCI49Dv4owdqSLj6pc/rgO67XIXWuLDBm5vLl4aUMuCdgIhANw5c3Pw1R9ma9Rv5D90qC2T3prOr3x7RYPoViRU73k/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4393,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisMpzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqsqg/7BzaxxgzJBgiVBgLlS9cIkrZ616JPfoBE4v5d/JNawvKJeWOm\r\nv+DogtTMzJ7ZqI82Hwe+2hF1nYMpO0uVccylpcKUd0jLTehIbSFskZxgBlcr\r\ntiI6SsOAQRCPqOf5Nm1jJSiqK4wnGTCCr14Z13f2dPbQ1JKWHgVV+hkGbhCn\r\nEyWA1RTeZrkDDiH5HfCLWzS6xYP8/NaawBbiwAVsag4CIVk9tVK6ioBXJEi+\r\nb2oq8aTkGk1J1Pnsxg9+ZHJy3z5nd24ngoUpQ/JSpi44DSBlKOqG8rLEXOvn\r\nvdoUpXk2XJK7Pjr2soKVg+dqC43an4tz7ZYVmsv3kgh+GjU1Fc6KZF+pPJAq\r\n6V6kUjIB/+217UcGOhOfulCH3F6bKUBDT/2mrWIq5pJAg83XDu+zYJdMGq5h\r\ney1n3CDrcpTdZmj8/S0+9U3SWytqqmqXAE7G2Mpv278HSrkwfHkHmlje7KAI\r\nq+a98+ClQjn2Iuk3ORwSkeR1Jddvrr4RdxGeps3t2/uRtYvKPui+9UGBLtE8\r\nAENkUppDELJlZzbAfFRkgqZpnKNHu8DZWLMOS1cD5XpFDRzPDapoGEJCBAUW\r\nOhA38mxM3wBNDHYmp1XiC4OBtbS15fO3QyiR5SaPu3ARBezsyqDc5R6r3KsJ\r\nI1ckufV4HrQxxTXZvAaMS40trfnp+Ah8Z54=\r\n=gTQ9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","private":false,"_npmUser":{"name":"pkuepers","email":"pkuepers@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-global-page-state.git","type":"git"},"description":"Module based state that allows communication between different client React 'islands' on the same page","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2021 kaliber.js\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","sideEffects":false,"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-global-page-state_1.0.0_1655753331543_0.4074327696345339","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-06-20T19:28:51.458Z","modified":"2026-09-09T12:43:27.089Z","1.0.0":"2022-06-20T19:28:51.755Z"},"license":"MIT","keywords":["react","global state","state"],"repository":{"url":"https://github.com/kaliberjs/use-global-page-state.git","type":"git"},"description":"Module based state that allows communication between different client React 'islands' on the same page","maintainers":[{"email":"davey@kaliber.net","name":"daveykropf"},{"email":"ewestra@kaliber.net","name":"eecolor"},{"email":"jduijm@kaliber.net","name":"jerryduijm"},{"email":"development@kaliber.net","name":"kaliber-owner"},{"email":"nhoenderop@kaliber.net","name":"nhoenderop"},{"email":"jbrunemann@kaliber.net","name":"janbru"},{"email":"asmit@kaliber.net","name":"albertkaliber"},{"email":"mvanbrakel@kaliber.net","name":"mvanbrakel"},{"email":"Rvanschaik@kaliber.net","name":"r0h-oh"},{"email":"claan@kaliber.net","name":"1cln"},{"email":"mreimus@kaliber.net","name":"maart-22"},{"email":"ldavidsondescelles@kaliber.net","name":"yoreljenkins"},{"email":"mdevalk@kaliber.net","name":"mdevalk1983"},{"email":"guido.evertzen@gmail.com","name":"guido.evertzen"},{"email":"svroom@kaliber.net","name":"svroom-kaliber"},{"email":"tomharms93@proton.me","name":"tomharms"},{"email":"rinus.vh@hotmail.com","name":"rinus.vh"},{"email":"pgoddijn@gmail.com","name":"pgoddijn"},{"email":"jvankralingen@kaliber.net","name":"jvankralingen"}],"readme":"# @kaliber/use-global-page-state\nModule based state that allows communication between different client React 'islands' on the same page.\n\n## Motivation\nWith @kaliber/build it has become easy to serve a React page component server side and only mount components client side when they contain interactivity. The downside of this, is that these interactive parts live on theire own isolated islands: they can't easily communicate. This library introduces the `useGlobalPageState` hook, which works comparable to React's `useState`, but syncs state between uses of this hook that provide the same id.\n\n## Installation\n\n```\nyarn add @kaliber/use-global-page-state\n```\n\n## Usage\n\n*Home.js*\n```jsx\nimport { ServerSideComponent } from '/features/pageOnly/ServerSideComponent'\nimport ClientSideComponentA from '/features/pageOnly/ClientSideComponentA.universal'\nimport ClientSideComponentB from '/features/pageOnly/ClientSideComponentB.universal'\n\nexport function Home() {\n  return (\n    <main>\n      <ClientSideComponentA />\n      <ServerSideComponent />\n      <ClientSideComponentB />\n    </main>\n  )\n}\n```\n\n*ClientSideComponentA.js*\n```jsx\nimport { useGlobalPageState } from '@kaliber/use-global-page-state'\n\nexport function ClientSideComponentA() {\n  const [state, setState] = useGlobalPageState('unique-id')\n  return (\n    <section>\n      {/* ... */}\n    </section>\n  )\n}\n```\n\n*ClientSideComponentB.js*\n```jsx\nimport { useGlobalPageState } from '@kaliber/use-global-page-state'\n\nexport function ClientSideComponentA() {\n  const [state, setState] = useGlobalPageState('unique-id')\n  return (\n    <section>\n      {/* ... */}\n    </section>\n  )\n}\n```\n\n---\n\n![](https://media.giphy.com/media/find-a-good-gif/giphy.gif)\n\n## Disclaimer\nThis library is intended for internal use, we provide __no__ support, use at your own risk. It does not import React, but expects it to be provided, which [@kaliber/build](https://kaliberjs.github.io/build/) can handle for you.\n\nThis library is not transpiled.\n","readmeFilename":"readme.md"}