{"id":13989915,"url":"https://github.com/jxnblk/static-react","last_synced_at":"2025-04-05T23:05:28.986Z","repository":{"id":27952526,"uuid":"31445296","full_name":"jxnblk/static-react","owner":"jxnblk","description":"Zero-configuration CLI React static renderer","archived":false,"fork":false,"pushed_at":"2018-06-19T04:33:08.000Z","size":518,"stargazers_count":349,"open_issues_count":8,"forks_count":29,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T22:08:00.989Z","etag":null,"topics":["cli","react","static","zero-configuration"],"latest_commit_sha":null,"homepage":"","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/jxnblk.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}},"created_at":"2015-02-28T00:28:14.000Z","updated_at":"2025-03-27T21:37:25.000Z","dependencies_parsed_at":"2022-09-04T05:51:59.278Z","dependency_job_id":null,"html_url":"https://github.com/jxnblk/static-react","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxnblk%2Fstatic-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxnblk%2Fstatic-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxnblk%2Fstatic-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxnblk%2Fstatic-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jxnblk","download_url":"https://codeload.github.com/jxnblk/static-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411226,"owners_count":20934653,"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":["cli","react","static","zero-configuration"],"created_at":"2024-08-09T13:02:10.100Z","updated_at":"2025-04-05T23:05:28.968Z","avatar_url":"https://github.com/jxnblk.png","language":"JavaScript","readme":"\n# static-react\n\nZero-configuration CLI React static renderer\n\n[![Build Status][badge]](https://travis-ci.org/jxnblk/static-react)\n\n[badge]: https://img.shields.io/travis/jxnblk/static-react.svg?style=flat-square\n\n\n## Usage\n\n```\nnpm i -g static-react\n```\n\n```\nstatic-react RootComponent.js \u003e index.html\n```\n\nStatic-react include babel presets and React – there is no need to install them separately\n\n## Examples\n\nSee the [examples/](examples) directory\n\n## Fetching Data\n\nUse the `getInitialProps` static method to fetch data or get server-side props for things like CSS-in-JS libraries.\n\n```jsx\nimport React from 'react'\nimport fetch from 'isomorphic-fetch'\n\nexport default class extends React.Component {\n  static getInitialProps = async () =\u003e {\n    const data = await fetch('https://api.example.com/data')\n\n    return {\n      data\n    }\n  }\n\n  render () {\n    const { data } = this.props\n\n    return (\n      \u003chtml\u003e\n        \u003ch1\u003eData\u003c/h1\u003e\n        \u003cpre\u003e\n          {JSON.stringify(data, null, 2)}\n        \u003c/pre\u003e\n      \u003c/html\u003e\n    )\n  }\n}\n```\n\n## CSS-in-JS\n\nUse the `getInitialProps` to pass side effects from CSS-in-JS libraries as props.\n\n```jsx\nimport React from 'react'\nimport { Box } from 'rebass'\n\nexport default class Root extends React.Component {\n  static getInitialProps = async (app) =\u003e {\n    const { ServerStyleSheet } = require('styled-components')\n    const { renderToString } = require('react-dom/server')\n    const sheet = new ServerStyleSheet()\n    renderToString(\n      sheet.collectStyles(app)\n    )\n    const css = sheet.getStyleTags()\n    return { css }\n  }\n\n  static defaultProps = {\n    css: ''\n  }\n\n  render () {\n    const { css } = this.props\n\n    return (\n      \u003chtml\u003e\n        \u003chead\u003e\n          ${css}\n        \u003c/head\u003e\n        \u003cbody\u003e\n          \u003cBox px={3} py={4}\u003e\n            Beep boop\n          \u003c/Box\u003e\n        \u003c/body\u003e\n      \u003c/html\u003e\n    )\n  }\n}\n```\n\n---\n\nMIT License\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjxnblk%2Fstatic-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjxnblk%2Fstatic-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjxnblk%2Fstatic-react/lists"}