{"id":18632330,"url":"https://github.com/frejs/fre-server","last_synced_at":"2025-11-04T07:30:23.005Z","repository":{"id":42098687,"uuid":"226879418","full_name":"frejs/fre-server","owner":"frejs","description":"fre-server","archived":false,"fork":false,"pushed_at":"2023-01-05T02:37:59.000Z","size":613,"stargazers_count":0,"open_issues_count":10,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T07:42:52.369Z","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/frejs.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":"2019-12-09T13:35:02.000Z","updated_at":"2020-12-31T05:06:30.000Z","dependencies_parsed_at":"2023-02-03T06:31:42.737Z","dependency_job_id":null,"html_url":"https://github.com/frejs/fre-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frejs%2Ffre-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frejs%2Ffre-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frejs%2Ffre-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frejs%2Ffre-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frejs","download_url":"https://codeload.github.com/frejs/fre-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239427026,"owners_count":19636662,"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-11-07T05:11:46.037Z","updated_at":"2025-11-04T07:30:22.963Z","avatar_url":"https://github.com/frejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fre/server\n\n\u003e server rendering for fre, It is still in the experimental stage, do not use it for production environment.\n\n### Use\n\n```js\nconst { h } = require('fre')\nconst { renderToString, useAction } = require('fre/server')\n\nfunction App() {\n  const [posts, setPosts] = useState([])\n  useAction(async () =\u003e {\n    await axios.get('https://api.clicli.us/rank').then(res =\u003e {\n      setPosts(res.data.posts)\n    })\n  })\n  return (\n    \u003cdiv\u003e\n      {posts.map(item =\u003e (\n        \u003cli\u003e{item.title}\u003c/li\u003e\n      ))}\n    \u003c/div\u003e\n  )\n}\n\nrouter.get('/', async ctx =\u003e {\n  let content = await renderToString(\u003cApp /\u003e)\n  ctx.body = template.replace('\u003c!-- fre --\u003e', content)\n})\n```\n\n### RenderToString\n\n```js\nlet content = await renderToString(\u003cApp /\u003e)\nctx.body = template.replace('\u003c!-- fre --\u003e', content)\n```\n\n`renderToString` will return html strings, you can render with Koa or any other frameworks.\n\n### UseAction\n\n```js\nuseAction(async () =\u003e {\n  await axios.get('https://api.clicli.us/rank').then(res =\u003e {\n    // do somethins\n  })\n})\n```\n`useAction` is more like `useEffect`, but it has no cleanups, and it receives a promise function. the requests will excutes in server side.\n\n##### \nMIT ©[hkc452](https://github.com/hkc452) inspired by [preact]()","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrejs%2Ffre-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrejs%2Ffre-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrejs%2Ffre-server/lists"}