edge-city

#react#js#ssr

git clone https://git.pyrossh.dev/edge-city

edge-city is a next level meta-framework for react that runs only on edge runtimes


readme.md
bbc6ba4 1
<img src="https://github.com/pyrossh/edge-city/assets/1687946/29f61137-d467-4730-9368-29ffb259c192" width="200px">
bbc6ba4 2
cd5cf70 3
# edge-city
e284d5b 4
c35b08d 5
edge-city is a next level meta-framework for react that runs only on edge runtimes.  
4d1436e 6
It uses file system routing with streaming SSR + CSR to render pages.  
e284d5b 7
It is very opionated and has set of idiomatic ways of doing things.  
e284d5b 8
It has an inbuilt rpc mechanism to access server resources instead of a typical REST API.  
c35b08d 9
It aims to have almost the same router api as nextjs router for ease of use.  
e284d5b 10
5636e80 11
During development each request for a page is executed in a separate edge-runtime (miniflare/vercel) vm.  
4d1436e 12
During production each page is packaged to an esm function adapted to the platform of your choice.  
e284d5b 13
c35b08d 14
## Why?
2292a7c 15
* Its really hard to have a streaming SSR + CSR with automatic data rehydration setup in nextjs 13.  
4d1436e 16
* There is no meta-framework which runs your code in an edge simulated environment during development.  
5636e80 17
5636e80 18
## Requirements
5636e80 19
1. `node >= v20`
5636e80 20
2. `wrangler` for deploying to cloudflare page functions
5636e80 21
3. `vercel` for deploying to vercel edge runtime
e284d5b 22
9a2bce6 23
## DB access
2292a7c 24
Since it runs only on edge runtimes which run in a constrained browser environment, you have to use database drivers
2292a7c 25
which can run in the browser, basically utilize Ajax/Fetch/Websocket. Here is a list of some of them,
9a2bce6 26
9a2bce6 27
* [NeonDB serverless driver](https://github.com/neondatabase/serverless) - postgres
9a2bce6 28
* [Platnetscale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) - mysql
9a2bce6 29
* [Mongo Http](https://github.com/patrick-kw-chiu/mongo-http.js) - mongodb
9a2bce6 30
9a2bce6 31
e284d5b 32
### Supported platforms
e284d5b 33
1. [Cloudflare page functions](https://developers.cloudflare.com/pages/platform/functions/routing/)
4d1436e 34
2. [TODO][Vercel edge functions](https://vercel.com/docs/concepts/functions/edge-functions)
4d1436e 35
3. [TODO][Netlify edge functions](https://docs.netlify.com/edge-functions/overview/)
c35b08d 36
5636e80 37
## Developing
5636e80 38
5636e80 39
1. `node >= v20.2.0`
5636e80 40
2. `pnpm >= v8.5.1`
5636e80 41
8cd9e9a 42
### Todo[General]
011acde 43
1. Build a docs website
011acde 44
2. Add tests for bot
011acde 45
3. Add tests for runtime
011acde 46
4. Add E2E tests for example
011acde 47
5. Maybe move to vite for HMR goodness
8cd9e9a 48
8cd9e9a 49
### Todo[Cloudflare]
2292a7c 50
1. Fix 404 pages not routing on server