{"id":19872588,"url":"https://github.com/georgecht/partial-hydrate","last_synced_at":"2025-08-20T21:08:13.677Z","repository":{"id":215829946,"uuid":"739868905","full_name":"GeorgeCht/partial-hydrate","owner":"GeorgeCht","description":"Partial React hydration wrapper component based on screen width for faster responsive performances.","archived":false,"fork":false,"pushed_at":"2025-08-10T14:04:05.000Z","size":1106,"stargazers_count":3,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-10T16:14:17.613Z","etag":null,"topics":["hydrations","partial","reactjs","responsive"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/partial-hydrate","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/GeorgeCht.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-06T19:40:44.000Z","updated_at":"2024-04-09T18:15:58.000Z","dependencies_parsed_at":"2025-05-14T20:27:39.079Z","dependency_job_id":"b1a057e2-e084-4b01-a31c-c760c9dd6bc8","html_url":"https://github.com/GeorgeCht/partial-hydrate","commit_stats":null,"previous_names":["georgecht/partial-hydrate"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/GeorgeCht/partial-hydrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeCht%2Fpartial-hydrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeCht%2Fpartial-hydrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeCht%2Fpartial-hydrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeCht%2Fpartial-hydrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeorgeCht","download_url":"https://codeload.github.com/GeorgeCht/partial-hydrate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeorgeCht%2Fpartial-hydrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271385961,"owners_count":24750509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["hydrations","partial","reactjs","responsive"],"created_at":"2024-11-12T16:16:06.288Z","updated_at":"2025-08-20T21:08:13.654Z","avatar_url":"https://github.com/GeorgeCht.png","language":"TypeScript","readme":"# Partial Hydrate [![npm version][npm-image]][npm-url] ![npm bundle size](https://img.shields.io/bundlephobia/minzip/partial-hydrate?logo=npm) [![Downloads][downloads-image]][npm-url] [![Test](https://github.com/actions/checkout/actions/workflows/test.yml/badge.svg)](https://github.com/actions/checkout/actions/workflows/test.yml)\n\n## Introduction\n\n![intro](example.png)\nProvides a `\u003cPartialHydrate\u003e` component that conditionally _skips hydrating children_ by removing them from the DOM _before the first client render_. Removing them before ensures hydration is successful and there are no hydration mismatch errors.\n\n## Install\n\n```\nnpm i partial-hydrate\n```\n\n## Usage\n\n```tsx\n\u003cPartialHydrate\n  when={() =\u003e {\n    window.innerWidth \u003c= 680\n  }}\n\u003e\n  {/* My mobile component */}\n\u003c/PartialHydrate\u003e\n```\n\n## Props\n\n- `minWidth`: will render if window width is greater than `minWidth` value.\n- `maxWidth`: will render if window width is lesser than `maxWidth` value.\n- `when()`: `function` that must return `true` for the render to happen.\n\n### Use with minWidth and/or maxWidth\n\nYou can use the `minWidth` and/or `maxWidth` props individually or together to conditionally render components based on the window width. Here's an example:\n\n```tsx\nconst MyComponent = () =\u003e {\n  return (\n    \u003cPartialHydrate minWidth={768}\u003e\n      { /* Rendered if window width is greater than or equal to 768 pixels */ }\n    \u003c/PartialHydrate\u003e\n\n    \u003cPartialHydrate maxWidth={1024}\u003e\n      { /* Rendered if window width is less than or equal to 1024 pixels */ }\n    \u003c/PartialHydrate\u003e\n\n    \u003cPartialHydrate minWidth={768} maxWidth={1024}\u003e\n      { /* Rendered if window width is between 768 and 1024 pixels (inclusive) */ }\n    \u003c/PartialHydrate\u003e\n  )\n}\n```\n\n### Use with when()\n\nThe `when()` prop allows for a custom condition based on a function. It is particularly useful for your _dynamic conditions_. For example:\n\n```tsx\nconst MyComponent = () =\u003e {\n  return (\n    \u003cPartialHydrate when={() =\u003e someDynamicCondition()}\u003e\n      {/* Rendered if the custom condition specified in the `when()` function is true */}\n    \u003c/PartialHydrate\u003e\n  )\n}\n```\n\n## Use case\n\nWhen using React's server-side rendering, we often need to render components on the server even if they are conditional on the client _e.g. hidden based on window width_.\n\nIn order for hydration to succeed, the first client render must match the DOM (which is generated from the HTML returned by the server), otherwise we will get hydration mismatch errors. This means the component must be rendered again during the first client render.\n\nHowever, hydration is expensive, so we really don't want to pay that penalty only for the element to be hidden or removed immediately afterwards.\n\n## Caveats\n\nSo is this another react _responsive_ rendering library? Nope. If the prop conditions are not met, then `\u003cPartialHydrate\u003e`'s children are never rendered.\n\n#### ✋ Keep in mind\n\nAlso, keep in mind that using `\u003cPartialHydrate\u003e` does not work on window resize and it is not meant to!\n\n## Authors\n\nBased on a gist by [OliverJAsh](https://github.com/OliverJAsh). Developed, modified and maintained by [George Cht](https://github.com/GeorgeCht).\n\n- George Cht ([@GeorgeCht](https://github.com/GeorgeCht))\n- Oliver Joseph Ash ([@OliverJAsh](https://github.com/OliverJAsh))\n\n## License\n\n[MIT License](https://opensource.org/licenses/MIT)\n\n[downloads-image]: http://img.shields.io/npm/dm/partial-hydrate.svg\n[npm-url]: https://www.npmjs.com/package/partial-hydrate\n[npm-image]: http://img.shields.io/npm/v/partial-hydrate.svg\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgecht%2Fpartial-hydrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgecht%2Fpartial-hydrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgecht%2Fpartial-hydrate/lists"}