{"id":13837126,"url":"https://github.com/musawirali/preact-rpc","last_synced_at":"2025-09-03T06:04:36.897Z","repository":{"id":57329588,"uuid":"85360347","full_name":"musawirali/preact-rpc","owner":"musawirali","description":"React Pre-Rendering via RPC","archived":false,"fork":false,"pushed_at":"2017-05-05T19:52:39.000Z","size":260,"stargazers_count":29,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T13:21:25.278Z","etag":null,"topics":["golang","react","rpc","ruby-on-rails","server-side-rendering"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/musawirali.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":"2017-03-17T22:38:33.000Z","updated_at":"2023-04-27T09:40:54.000Z","dependencies_parsed_at":"2022-09-16T18:00:40.187Z","dependency_job_id":null,"html_url":"https://github.com/musawirali/preact-rpc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musawirali%2Fpreact-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musawirali%2Fpreact-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musawirali%2Fpreact-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/musawirali%2Fpreact-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/musawirali","download_url":"https://codeload.github.com/musawirali/preact-rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225648310,"owners_count":17502174,"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","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":["golang","react","rpc","ruby-on-rails","server-side-rendering"],"created_at":"2024-08-04T15:01:01.529Z","updated_at":"2024-11-20T23:32:24.132Z","avatar_url":"https://github.com/musawirali.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# preact-rpc\nReact Pre-Rendering via RPC\n\nA simple JSON based socket server that fulfills React component render requests.\n\n[![https://nodei.co/npm/preact-rpc.png?downloads=true\u0026downloadRank=true\u0026stars=true](https://nodei.co/npm/preact-rpc.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/preact-rpc)\n\nIntroduction and tutorial: [Server-side React Rendering From non-Node Environments](https://medium.com/@musawiralishah/server-side-react-rendering-from-non-node-environments-216021ad537d#.fzk015qwi)\n\nThe motivation for this project is to use React server-side rendering (aka pre-rendering) from a non-Node app, such as one\nwritten in Ruby, or Go.\n\nThe preact-rpc server loads a Javascript bundle file containing the React components, and starts listening for render requests\non a socket (a TCP socket or a UNIX socket file). A client, such as a Go app, can connect to the server and send a render request\nby providing a React component identifier and the props to use for rendering. The server returns with an HTML string, that can\nthen be embedded in a view served on the client side.\n\nInstall preact-rpc globally:\n\n```\nnpm install -g preact-rpc\n```\n\nIn your component JS bundle, register your components so that preact-rpc can find them:\n\n```\nimport { registerComponent } from 'preact-rpc';\n...\nregisterComponent('comp1', MyComponent);\nregisterComponent('comp2', MyOtherComponent);\n...\n```\n\nSee lib/example/component.js for example.\n\nNext, start the server. It requires the path to the bundle file and the port to listen on:\n\n```\npreact-rpc --bundle=./lib/example/component.js --port=tmp/server.sock\n```\n\nAn example Go client is provided in the example-clients directory. Run the app and visit http://localhost:8080\n\n```\ngo run example-clients/client.go\n```\n\nAn example Ruby client is also provided in the example-clients directory. Install the gem:\n\n```\ngem install preact-rpc-client\n```\n\nAnd then run the example:\n\n```\nruby example-clients/client.rb\n```\n\n## More to come:\nAdd support for Redux stores\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusawirali%2Fpreact-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmusawirali%2Fpreact-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmusawirali%2Fpreact-rpc/lists"}