{"id":17982350,"url":"https://github.com/pedrobslisboa/universal-portal","last_synced_at":"2026-02-04T03:03:35.391Z","repository":{"id":219347026,"uuid":"746737265","full_name":"pedrobslisboa/universal-portal","owner":"pedrobslisboa","description":"Universal Portal for ssr natively ReasonReact apps","archived":false,"fork":false,"pushed_at":"2025-05-28T13:42:00.000Z","size":377,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T02:26:17.163Z","etag":null,"topics":["reason-react","reasonml","server-side-rendering"],"latest_commit_sha":null,"homepage":"","language":"Reason","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pedrobslisboa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-22T15:20:00.000Z","updated_at":"2024-09-03T13:20:55.000Z","dependencies_parsed_at":"2025-07-08T01:44:03.915Z","dependency_job_id":"97eef08e-6ffb-49f8-a945-2d9a5811a750","html_url":"https://github.com/pedrobslisboa/universal-portal","commit_stats":null,"previous_names":["pedrobslisboa/universal-portal"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/pedrobslisboa/universal-portal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedrobslisboa%2Funiversal-portal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedrobslisboa%2Funiversal-portal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedrobslisboa%2Funiversal-portal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedrobslisboa%2Funiversal-portal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pedrobslisboa","download_url":"https://codeload.github.com/pedrobslisboa/universal-portal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedrobslisboa%2Funiversal-portal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29065677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T01:55:38.219Z","status":"online","status_checked_at":"2026-02-04T02:00:07.999Z","response_time":62,"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":["reason-react","reasonml","server-side-rendering"],"created_at":"2024-10-29T18:14:03.383Z","updated_at":"2026-02-04T03:03:35.365Z","avatar_url":"https://github.com/pedrobslisboa.png","language":"Reason","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca  href=\"https://github.com/pedrobslisboa/universal-portal#gh-light-mode-only\"\u003e\n    \u003cimg width=\"80%\" style=\"min-width:500px\" src=\"./lightmode.png\" alt=\"Universal Portal\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca  href=\"https://github.com/pedrobslisboa/universal-portal#gh-dark-mode-only\"\u003e\n    \u003cimg width=\"80%\" style=\"min-width:500px\"  src=\"./darkmode.png\" alt=\"Universal Portal\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Universal Reason Portal\n\nUniversal Portal for ssr natively ReasonReact apps.\n\nThis project was inspired by [server-reason-react](https://github.com/ml-in-barcelona/server-reason-react) to understand how SSR with ReasonReact works and also give the community more material to learn about SSR with ReasonReact.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Server](#server)\n  - [Shared](#shared)\n- [Running the demo](#running-the-demo)\n\n## Installation\n\n```sh\nopam install universal-portal\n```\n\n## Usage\n\n### Server\n\n```reason\n  Dream.router([\n    Dream.get(\"/\", _request =\u003e {\n      let portals: ref(array(UniversalPortal_Shared.Portal.portal)) = ref([||]);\n\n      let element =\n        ReactDOM.renderToString(\n          UniversalPortal_Server.collectPortals(\n            \u003cPage scripts=[\"/static/app.js\"]\u003e\n              \u003cShared_native_demo.App /\u003e\n            \u003c/Page\u003e,\n            (collectedPortal: UniversalPortal_Shared.Portal.portal) =\u003e {\n            portals := Array.append(portals^, [|collectedPortal|])\n          }),\n        );\n\n      let html =\n        UniversalPortal_Server.appendUniversalPortals(element, portals^);\n\n      portals := [||];\n\n      html |\u003e Dream.html;\n    }),\n    Dream.get(\"/static/**\", Dream.static(\"./static\")),\n  ]);\n```\n\n### Shared\n\n#### For client dune config add\n\n```dune\n (libraries universal-portal.shared_js)\n```\n\n#### For native dune config add\n\n```dune\n (libraries universal-portal.shared_native)\n```\n\n#### Component\n\nUse `UniversalPortal_Shared` and it will work on both client and native content.\n\n```reason\n[@react.component]\nlet make = () =\u003e {\n  \u003cdiv\u003e\n    \u003cUniversalPortal_Shared.Portal selector=\"body\"\u003e\n      \u003cdiv\u003e\n        {\"Hey, I'm a portal, disable JS on your dev tools and check that I'll still here\"\n          |\u003e React.string}\n      \u003c/div\u003e\n    \u003c/UniversalPortal_Shared.Portal\u003e\n  \u003c/div\u003e;\n};\n```\n\n#### Cleaning server side portals\n\nYou must call the `UniversalPortal_Js.useRemoveServerPortals` at the main entry point of your app, so it will remove all the server side portals.\n\nCheckout the demo for more details: [Demo](/demo/shared/native/App.re#L3-L9)\n\n```reason\n  UniversalPortal_Js.useRemoveServerPortals();\n```\n\n## Running the demo\n\nMake sure to initialize the project:\n\n```sh\nmake init\n```\n\nThen you can run the demo:\n\n```sh\nmake demo\n```\n\n## Roadmap\n\n- [ ] Improve tests","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrobslisboa%2Funiversal-portal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedrobslisboa%2Funiversal-portal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrobslisboa%2Funiversal-portal/lists"}