• Stars
    star
    694
  • Rank 65,170 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐙 Resumable SSR framework.

image

Asta NPM version NPM downloads

🎯 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.

Note this is early Development! It is not recommended to use this for anything serious yet.

  • no VDOM on server, 0 javascript on client.
  • write JSX and react-like syntax.

Run demo

yarn start

Syntax

input:

const addCount = $import('./action.js#addCount')

// state: will run in server and inject to client
export const loader = async (req) => {
	return {
		count: req.query.count,
	}
}

// view: will run in both client and server, but s() in server h() in client
export default ({ count }) => {
	return (
		<main>
			<button onclick={addCount}>{count}</button>
		</main>
	)
}

output:

<main><button $onclick="./action/count.js?mod=addCount">0</button></main>

Compiler

Jointing on server, Resumable on client

// jsx input
const view = ({list}) => <div>{list.map(i=><i>{i}</i>)}</div>
// server output
const view = ({list}) => s.openTag('div')+s.expression(list.map(i=>s.openTag('i')+s.text(i)+s.closeTag('i')))+s.closeTag('div')
// client output
const view = ({list}) => h('div',{children:[list.map(i=>h('i',{children:[i]}))]})

How and why

How is This Different from Next.js, Remix.js, Fresh.js or Other SSR Solutions?

There are two biggest differences.

First, 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.

Second, 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.

So, Asta ≈ Marko + Qwik.

Because there is no Vdom overhead on the server side, Asta can get super high QPS and throughput.

Then 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.

How is This Different from Qwik.js or Marko.js?

In principle, asta is the sum of them, Asta is a double optimization, but the implementation details are quite different.

At the same time, Asta attempts to migrate Elm's mental model to SSR.

There is only a single state tree, and components are pure functions without states or any overhead.

These helps to completely solve performance problems.

Why not Fre SSR or and other Vdom-based frameworks?

Although 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.

说人话?

Asta 的核心是根治性能问题,已知的 SSR 框架有几个性能瓶颈:

  1. server 端的 vdom 开销,组件开销
  • server 端生成和遍历 vdom 成本是巨大的,Asta 在 server 端没有 vdom,它通过一个特殊的编译器将 jsx 编译成 s 函数,只用来拼接字符串

  • server 端组件的初始化,状态更新,生命周期的开销,也是巨大的,Asta 也有组件,但它的组件是纯函数,也只用来拼接字符串,没有任何私有状态和生命周期,这得益于 Elm 的心智模型,单 state tree,组件是纯函数

  1. client 0 js
  • 一个新兴的概念,叫做 Resumable,client 不再水合,而是将必要的信息序列化到 html 里,然后直接从 html 进行恢复,所有的 js 都根据交互懒加载,这样就可以做到 0 js,0 水合,而且这是 O(1) 的,不会因为业务增长而性能下降

Asta 双重优化,彻底根除 SSR 的性能瓶颈

More Repositories

1

eplayer

🔮 A web-component html5 video player facing future
JavaScript
269
star
2

labor

Simple implementation of Web Container
Go
188
star
3

smallapp

🎃 基于 fre 的小程序架构
JavaScript
163
star
4

fard2

🎅 fre 转小程序的新思路 ♂ learn once, write anywhere.
JavaScript
114
star
5

homo

Lightweight Rendering engine similar to Harmony, but use Fre and quickjs
C
59
star
6

deku

⛄️ No-bundle Dev Server for ES modules with deno.
JavaScript
51
star
7

joke

🎃 Tiny Javascript engine, does not support Typescript (yet).
Rust
45
star
8

peacecss

Golang implement of postcss.
Go
43
star
9

soga

Tiny layout engine.
Rust
40
star
10

wxml

wxml parser rust implement
Rust
39
star
11

oplayer

👾 react native video player for expo
JavaScript
25
star
12

node_swc

swc node binding use wasm
Rust
23
star
13

venti

Simple Vue SSR framework
JavaScript
21
star
14

loki-admin

Admin app build by KokiUI
JavaScript
14
star
15

fremix

Remix for fre
JavaScript
13
star
16

gei

👾 Fast 1kb sprites system with webgl.
JavaScript
13
star
17

tinyMDE

1kb markdown 编辑器
JavaScript
12
star
18

picopack

📦 Simple Typescript library bundler.
TypeScript
11
star
19

dirty-check

reactivity system with dirty checking
JavaScript
10
star
20

bad-scroll

100 lines scroll for mobile UI
JavaScript
8
star
21

m3u8.js

🌀 m3u8 client using WebAssembly and Media Source Extension
JavaScript
8
star
22

frekit

Streaming rendering for fre SSR
6
star
23

smox-counter

A redux-like state management which based on New context api
JavaScript
5
star
24

color-picker

Auto pick the primary color.
JavaScript
5
star
25

uraban-typecho-themes

typecho themes
PHP
4
star
26

fplayer

flutter player for clicli.tv
4
star
27

bale

Zero configuration builder.
4
star
28

voe2

Concurrent rendering engine.
JavaScript
4
star
29

TinyScript

Tiny javascript engine writted by rust.
4
star
30

gan

👾 A web framework packaged Go native which use fasthttp and httprouter
Go
3
star
31

vue-ssr

A vue-ssr demo
JavaScript
3
star
32

js-parser

Coarse-grained JavaScript block parser.
3
star
33

hello_wasm

hello wasm
JavaScript
3
star
34

remix-client

JavaScript
3
star
35

voe-ide

A ide for mini programs
3
star
36

kiana

the moe plugin of kiana
JavaScript
2
star
37

fre-sortable-tree

2
star
38

1990

2
star
39

opration-task-queue

JavaScript
2
star
40

rexpr

JavaScript expression parser
2
star
41

juvenile

Simple CICD
Go
2
star
42

fre3

fre3 临时仓库
Rust
2
star
43

moe-comment

1kb severless comment system
2
star
44

varix

Remix for vue
2
star
45

immix

Create next immutable patch by mutating the current.
JavaScript
2
star
46

yisar

2
star
47

cplayer

Simple video player UI for clicli app.
2
star
48

browser-cjs

JavaScript
2
star
49

esbuild-module-federation

2
star
50

requestIdlePromise

A POC for requestIdleCallback used Promise
JavaScript
2
star
51

fre-jotal

2
star
52

easy-crypto

Easy crpto use WebAssembly
JavaScript
2
star
53

ukagaka

this is a ukagaka plugin
JavaScript
2
star
54

blockchain-cli

cli for blockchain
JavaScript
2
star
55

tiga

Faster taro alternative.
Go
2
star
56

acgzone-moblie

acgzone mobile app written by react native
2
star
57

smox-todo

todolist for react and smox
2
star
58

fre-server-component

1
star
59

xiuno

Xino is a lightweight PHP forum system.
1
star
60

fre-counter

A demo for Fre
TypeScript
1
star
61

super-element

JSX alternative with swiftUI like syntax.
1
star
62

webpack-vemix--manifest

1
star
63

typeditor

🍡 A markdown editor rewriting of typecho's
TypeScript
1
star
64

webview_video_player

Flutter video player with webview plugin.
1
star
65

jio

sm app build by react-native
1
star
66

fre-realword

A real world APP for Fre
1
star
67

UIwidgets

this is a simple slider
JavaScript
1
star
68

wean-demo-tuchong

A wean demo for tuchong.com
JavaScript
1
star
69

hvec

A simple javascript hvec_H265 muxer.
1
star
70

demon

A javascript framework for deno
1
star
71

danmu

danmuku for clicli
JavaScript
1
star
72

priority-scheduler

React scheduler implement.
1
star
73

snel

Html-first framework
JavaScript
1
star
74

js-basic-skill

js-basic-skill
1
star
75

gap

A simple and lightweight REST server framework.
1
star
76

duex

Another state manager make Redux use Vuex-like syntax
1
star
77

phpbb1

phpbb1 for php8
PHP
1
star