{"id":17349234,"url":"https://github.com/co2-git/reacted-express","last_synced_at":"2025-03-27T11:44:25.873Z","repository":{"id":68259429,"uuid":"49769526","full_name":"co2-git/reacted-express","owner":"co2-git","description":"Express middleware to render React components","archived":false,"fork":false,"pushed_at":"2016-03-23T23:18:00.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T16:23:17.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/co2-git.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-01-16T10:44:57.000Z","updated_at":"2016-01-16T10:45:15.000Z","dependencies_parsed_at":"2023-04-15T11:16:12.973Z","dependency_job_id":null,"html_url":"https://github.com/co2-git/reacted-express","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Freacted-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Freacted-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Freacted-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Freacted-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co2-git","download_url":"https://codeload.github.com/co2-git/reacted-express/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841690,"owners_count":20681184,"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":[],"created_at":"2024-10-15T16:55:07.490Z","updated_at":"2025-03-27T11:44:25.854Z","avatar_url":"https://github.com/co2-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"reacted-express\n===\n\nReact rendering server-side using Express\n\n# Install\n\n```bash\nnpm install -s reacted-express\n```\n\n# Usage\n\n```js\n// Your React component you want to render server-side\n// components/app.jsx\nimport React from 'react';\n\nexport default class App extends React.Component {\n  render () {\n    return (\n      \u003ch1\u003eHello { this.props.person }\u003c/h1\u003e\n    );\n  }\n}\n\n// In your express file\n\n// Use reacted express as a middleware in your express file\n\nimport renderReact from 'reacted-express';\n\n// ...\n\napp = express();\n\n// Renders App component as a HTML view\n\napp.use('/', renderReact(App, { person : 'Joe' }));\n\n// Voila!\n\n// ...\n```\n\n# Inject a React component into a HTML source\n\nSometimes you want to inject your main component into a HTML source.\n\n```html\n\u003c!-- index.html --\u003e\n\u003c!doctype html\u003e\n\u003ctitle\u003eTest React App\u003c/title\u003e\n\u003c!-- This is the section you want to replace --\u003e\n\u003csection\u003eLoading\u003c/section\u003e\n\u003c!-- Where the back-end props are copied --\u003e\n\u003cscript\u003ewindow.reactProps = /* props */\u003c/script\u003e\n```\n\n```js\n\n// ...\n\napp = express();\n\n\n// Will render the source of index.html\n// ... and replace 'Loading' by the HTML of MyComponent\n\napp.use(renderReact(App, { person : 'Jessie' }, {\n  inject : {\n    into : 'index.html',\n    where : 'Loading',\n    // where to copy props\n    props : '/* props */' // will output { \"person\" : \"Jessie\" }\n  }\n}));\n\n// ...\n\n```\n\n# Pass `props` to client\n\n```js\napp.use(renderReact(App, (req, res) =\u003e {}, { send : false }));\n\napp.use((req, res, next) =\u003e {\n  req.reactedExpress.rendered\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Freacted-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco2-git%2Freacted-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Freacted-express/lists"}