{"id":13511345,"url":"https://github.com/yisar/asta","last_synced_at":"2025-04-13T05:04:42.341Z","repository":{"id":36098618,"uuid":"127891796","full_name":"yisar/asta","owner":"yisar","description":":octopus: Resumable SSR framework.","archived":false,"fork":false,"pushed_at":"2025-02-10T22:02:41.000Z","size":4609,"stargazers_count":723,"open_issues_count":2,"forks_count":60,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-13T05:04:04.101Z","etag":null,"topics":["resumable","server-side-rendering","ssr"],"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/yisar.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":"2018-04-03T10:32:11.000Z","updated_at":"2025-04-07T16:36:45.000Z","dependencies_parsed_at":"2023-02-16T17:16:04.947Z","dependency_job_id":null,"html_url":"https://github.com/yisar/asta","commit_stats":null,"previous_names":["yisar/doux","132yse/smox","yisar/voe"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisar%2Fasta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisar%2Fasta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisar%2Fasta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisar%2Fasta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yisar","download_url":"https://codeload.github.com/yisar/asta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665748,"owners_count":21142123,"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":["resumable","server-side-rendering","ssr"],"created_at":"2024-08-01T03:00:47.906Z","updated_at":"2025-04-13T05:04:42.307Z","avatar_url":"https://github.com/yisar.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"300\" alt=\"image\" src=\"https://user-images.githubusercontent.com/12951461/196841960-7e297a6d-0a83-4343-b4a2-8b4caa0f858b.png\"\u003e\u003c/p\u003e\n\n\n# Asta [![NPM version](https://img.shields.io/npm/v/asta.svg)](https://npmjs.com/package/asta) [![NPM downloads](https://img.shields.io/npm/dt/eplayer.svg)](https://npmjs.com/package/asta)\n\n:dart: Asta is a highly specialized full stack framework for SSR. It has no vdom on the server side and 0 js on the client side. Finally, it gets best QPS and Google scores.\n\n\u003e Note this is early Development! It is not recommended to use this for anything serious yet.\n\n- no VDOM on server, 0 javascript on client.\n- write JSX and react-like syntax.\n\n\n\n### Run demo\n\n```shell\nyarn start\n```\n\n\n### Syntax\n\ninput:\n\n```jsx\nconst addCount = $import('./action.js#addCount')\n\n// state: will run in server and inject to client\nexport const loader = async (req) =\u003e {\n\treturn {\n\t\tcount: req.query.count,\n\t}\n}\n\n// view: will run in both client and server, but s() in server h() in client\nexport default ({ count }) =\u003e {\n\treturn (\n\t\t\u003cmain\u003e\n\t\t\t\u003cbutton onclick={addCount}\u003e{count}\u003c/button\u003e\n\t\t\u003c/main\u003e\n\t)\n}\n```\n\noutput:\n\n```html\n\u003cmain\u003e\u003cbutton $onclick=\"./action/count.js?mod=addCount\"\u003e0\u003c/button\u003e\u003c/main\u003e\n```\n\n### Compiler\n\nJointing on server, Resumable on client\n\n```js\n// jsx input\nconst view = ({list}) =\u003e \u003cdiv\u003e{list.map(i=\u003e\u003ci\u003e{i}\u003c/i\u003e)}\u003c/div\u003e\n// server output\nconst view = ({list}) =\u003e s.openTag('div')+s.expression(list.map(i=\u003es.openTag('i')+s.text(i)+s.closeTag('i')))+s.closeTag('div')\n// client output\nconst view = ({list}) =\u003e h('div',{children:[list.map(i=\u003eh('i',{children:[i]}))]})\n```\n\n# How and why\n\n### How is This Different from Next.js, Remix.js, Fresh.js or Other SSR Solutions?\n\nThere are two biggest differences. \n\nFirst, the server side. Asta does not run any VDOM-based framework runtime. It generates the `s function` through the compiler, which is only used for string splicing. At this point, it is a little like Marko.js.\n\nSecond, on the client side, Asta is 0 javascript, and it does not require any hydration. This is a new concept, called Resumable, a little like qwik.js.\n\nSo, `Asta ≈ Marko + Qwik`.\n\nBecause there is no Vdom overhead on the server side, Asta can get super high QPS and throughput.\n\nThen because the client side is 0 js, it can continuously get a high Google score, and the score will not decrease with the increase of components.\n\n### How is This Different from Qwik.js or Marko.js?\n\nIn principle, asta is the sum of them, Asta is a double optimization, but the implementation details are quite different.\n\nAt the same time, Asta attempts to migrate Elm's mental model to SSR. \n\nThere is only a single state tree, and components are pure functions without states or any overhead. \n\nThese helps to completely solve performance problems.\n\n### Why not Fre SSR or and other Vdom-based frameworks?\n\nAlthough JSX of fre can also be optimized at compile time, and the client side can also be selective hydrated, it is important that Fre or other Vdom-based framework components are not completely cost free.\n\n### 说人话？\n\nAsta 的核心是根治性能问题，已知的 SSR 框架有几个性能瓶颈：\n\n1. server 端的 vdom 开销，组件开销\n\n- server 端生成和遍历 vdom 成本是巨大的，Asta 在 server 端没有 vdom，它通过一个特殊的编译器将 jsx 编译成 s 函数，只用来拼接字符串\n\n- server 端组件的初始化，状态更新，生命周期的开销，也是巨大的，Asta 也有组件，但它的组件是纯函数，也只用来拼接字符串，没有任何私有状态和生命周期，这得益于 Elm 的心智模型，单 state tree，组件是纯函数\n\n2. client 0 js\n\n- 一个新兴的概念，叫做 Resumable，client 不再水合，而是将必要的信息序列化到 html 里，然后直接从 html 进行恢复，所有的 js 都根据交互懒加载，这样就可以做到 0 js，0 水合，而且这是 O(1) 的，不会因为业务增长而性能下降\n\nAsta 双重优化，彻底根除 SSR 的性能瓶颈\n\n\n","funding_links":[],"categories":["react","JavaScript",":clap: 欢迎参与​"],"sub_categories":["工具库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisar%2Fasta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyisar%2Fasta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisar%2Fasta/lists"}